source: GTP/trunk/Lib/Vis/Preprocessing/src/FromPointVisibilityTree.h @ 2575

Revision 2575, 23.4 KB checked in by bittner, 17 years ago (diff)

big merge: preparation for havran ray caster, check if everything works

Line 
1#ifndef _FromPointVisibilityTree_H__
2#define _FromPointVisibilityTree_H__
3
4#include <stack>
5#include <fstream>
6
7#include "Mesh.h"
8#include "Containers.h"
9#include "Polygon3.h"
10#include "Statistics.h"
11#include "VssRay.h"
12#include "RayInfo.h"
13#include "ViewCellBsp.h"
14
15namespace GtpVisibilityPreprocessor {
16
17class ViewCell;
18class Plane3;
19class FromPointVisibilityTree; 
20class BspInterior;
21class BspNode;
22class AxisAlignedBox3;
23class Ray;
24class ViewCellsStatistics;
25class ViewCellsManager;
26class MergeCandidate;
27class Beam;
28class ViewCellsTree;
29
30
31
32/** A location in space representing from point-visibility.
33*/
34struct VisibilityPoint
35{
36        Vector3 mPosition;
37
38        /// from point visibility => visible objects, not potentially
39        ObjectPvs mVisibleObjects;
40};
41
42
43/**
44        This is a tree which partitions from point queries in a greedy optimal fashion.
45*/
46class FromPointVisibilityTree
47{
48        friend class ViewCellsParseHandlers;
49        friend class VspBspViewCellsManager;
50
51public:
52       
53        /** Additional data which is passed down the BSP tree during traversal.
54        */
55        class VspBspTraversalData
56        { 
57        public:
58                /// the current node
59                BspNode *mNode;
60                /// polygonal data for splitting
61                PolygonContainer *mPolygons;
62                /// current depth
63                int mDepth;
64                /// rays piercing this node
65                RayInfoContainer *mRays;
66                /// the probability that this node contains view point
67                float mProbability;
68                /// geometry of node as induced by planes
69                BspNodeGeometry *mGeometry;
70                /// pvs size
71                int mPvs;
72                /// how often this branch has missed the max-cost ratio
73                int mMaxCostMisses;
74                /// if this node is a kd-node (i.e., boundaries are axis aligned
75                bool mIsKdNode;
76                // current axis
77                int mAxis;
78                // current priority
79                float mPriority;
80
81               
82                /** Returns average ray contribution.
83                */
84                float GetAvgRayContribution() const
85                {
86                        return (float)mPvs / ((float)mRays->size() + Limits::Small);
87                }
88
89
90                VspBspTraversalData():
91                mNode(NULL),
92                mPolygons(NULL),
93                mDepth(0),
94                mRays(NULL),
95                mPvs(0),
96                mProbability(0.0),
97                mGeometry(NULL),
98                mMaxCostMisses(0),
99                mIsKdNode(false),
100                mPriority(0),
101                mAxis(0)
102                {}
103               
104                VspBspTraversalData(BspNode *node,
105                                                        PolygonContainer *polys,
106                                                        const int depth,
107                                                        RayInfoContainer *rays,
108                                                        const int pvs,
109                                                        const float p,
110                                                        BspNodeGeometry *geom):
111                mNode(node),
112                mPolygons(polys),
113                mDepth(depth),
114                mRays(rays),
115                mPvs(pvs),
116                mProbability(p),
117                mGeometry(geom),
118                mMaxCostMisses(0),
119                mIsKdNode(false),
120                mPriority(0),
121                mAxis(0)
122                {}
123
124                VspBspTraversalData(PolygonContainer *polys,
125                                                        const int depth,
126                                                        RayInfoContainer *rays,
127                                                        BspNodeGeometry *geom):
128                mNode(NULL),
129                mPolygons(polys),
130                mDepth(depth),
131                mRays(rays),
132                mPvs(0),
133                mProbability(0),
134                mGeometry(geom),
135                mMaxCostMisses(0),
136                mIsKdNode(false),
137                mAxis(0)
138                {}
139
140                /** Returns cost of the traversal data.
141                */
142                float GetCost() const
143                {
144                        //cout << mPriority << endl;
145                        return mPriority;
146                }
147
148                // deletes contents and sets them to NULL
149                void Clear()
150                {
151                        DEL_PTR(mPolygons);
152                        DEL_PTR(mRays);
153                        DEL_PTR(mGeometry);
154                }
155
156                friend bool operator<(const VspBspTraversalData &a, const VspBspTraversalData &b)
157                {
158                        return a.GetCost() < b.GetCost();
159                }
160    };
161       
162
163        typedef std::priority_queue<VspBspTraversalData> VspBspTraversalQueue;
164       
165       
166        struct VspBspSplitCandidate
167        { 
168                /// the current node
169                Plane3 mSplitPlane;
170                /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
171                int mSplitAxis;
172                /// the number of misses of max cost ratio until this split
173                int mMaxCostMisses;
174
175                // parent data
176                VspBspTraversalData mParentData;
177                // cost of applying this split
178                float mRenderCost;
179
180                VspBspSplitCandidate(): mRenderCost(0)
181                {};
182
183                VspBspSplitCandidate(const Plane3 &plane, const VspBspTraversalData &tData):
184                mSplitPlane(plane), mParentData(tData), mRenderCost(0)
185                {}
186
187                /** Returns cost of the traversal data.
188                */
189                float GetCost() const
190                {
191#if 1
192                        return mRenderCost;
193#endif
194#if 0
195                        return (float) (-mDepth); // for kd tree
196#endif
197                }
198
199                friend bool operator<(const VspBspSplitCandidate &a, const VspBspSplitCandidate &b)
200                {
201                        return a.GetCost() < b.GetCost();
202                }
203    };
204
205        typedef std::priority_queue<VspBspSplitCandidate> VspBspSplitQueue;
206
207        /** Default constructor creating an empty tree.
208        */
209        FromPointVisibilityTree();
210
211        /** Default destructor.
212        */
213        ~FromPointVisibilityTree();
214
215        /** Returns BSP Tree statistics.
216        */
217        const BspTreeStatistics &GetStatistics() const;
218 
219
220        /** Constructs the tree from a given set of rays.
221                @param sampleRays the set of sample rays the construction is based on
222        */
223        void Construct(const VssRayContainer &sampleRays,
224                                   AxisAlignedBox3 *forcedBoundingBox);
225
226       
227        /** Constructs the tree from a given set of visibility points
228                @param visibiltiyPointe visibility points the construction is based on
229        */
230        void Construct(const VisibilityPointsContainer &visibilityPoints,
231                                   AxisAlignedBox3 *forcedBoundingBox);
232
233        /** Returns list of BSP leaves with pvs smaller than
234                a certain threshold.
235                @param onlyUnmailed if only the unmailed leaves should be considered
236                @param maxPvs the maximal pvs (-1 means unlimited)
237        */
238        void CollectLeaves(vector<BspLeaf *> &leaves,
239                                           const bool onlyUnmailed = false,
240                                           const int maxPvs = -1) const;
241
242        /** Returns box which bounds the whole tree.
243        */
244        AxisAlignedBox3 GetBoundingBox()const;
245
246        /** Returns root of BSP tree.
247        */
248        BspNode *GetRoot() const;
249
250        /** Collects the leaf view cells of the tree
251                @param viewCells returns the view cells
252        */
253        void CollectViewCells(ViewCellContainer &viewCells, bool onlyValid) const;
254
255        /** A ray is cast possible intersecting the tree.
256                @param the ray that is cast.
257                @returns the number of intersections with objects stored in the tree.
258        */
259        int CastRay(Ray &ray);
260        int CastSimpleRay(const SimpleRay &ray) { return 0;}
261        int CastSimpleRay(const SimpleRay &ray, int IndexRay) { return 0;}
262
263        /// bsp tree construction types
264        enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_SAMPLES};
265
266        /** finds neighbouring leaves of this tree node.
267        */
268        int FindNeighbors(BspNode *n,
269                                          vector<BspLeaf *> &neighbors,
270                                          const bool onlyUnmailed) const;
271
272        /** Constructs geometry associated with the half space intersections
273                leading to this node.
274        */
275        void ConstructGeometry(BspNode *n, BspNodeGeometry &geom) const;
276       
277        /** Construct geometry of view cell.
278        */
279        void ConstructGeometry(ViewCell *vc, BspNodeGeometry &geom) const;
280
281        /** Returns random leaf of BSP tree.
282                @param halfspace defines the halfspace from which the leaf is taken.
283        */
284        BspLeaf *GetRandomLeaf(const Plane3 &halfspace);
285
286        /** Returns random leaf of BSP tree.
287                @param onlyUnmailed if only unmailed leaves should be returned.
288        */
289        BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false);
290
291        /** Returns epsilon of this tree.
292        */
293        float GetEpsilon() const;
294
295        /** Casts line segment into the tree.
296                @param origin the origin of the line segment
297                @param termination the end point of the line segment
298                @returns view cells intersecting the line segment.
299        */
300    int CastLineSegment(const Vector3 &origin,
301                                                const Vector3 &termination,
302                                                ViewCellContainer &viewcells);
303
304               
305        /** Sets pointer to view cells manager.
306        */
307        void SetViewCellsManager(ViewCellsManager *vcm);
308
309        /** Returns distance from node 1 to node 2.
310        */
311        int TreeDistance(BspNode *n1, BspNode *n2) const;
312
313        /** Collapses the tree with respect to the view cell partition.
314                @returns number of collapsed nodes
315        */
316        int CollapseTree();
317
318        /** Returns view cell the current point is located in.
319        */
320        ViewCell *GetViewCell(const Vector3 &point);
321
322
323        /** Returns true if this view point is in a valid view space,
324                false otherwise.
325        */
326        bool ViewPointValid(const Vector3 &viewPoint) const;
327
328        /** Returns view cell corresponding to
329                the invalid view space.
330        */
331        BspViewCell *GetOutOfBoundsCell();
332
333        /** Writes tree to output stream
334        */
335        bool Export(std::ofstream &stream);
336
337        /** Casts beam, i.e. a 5D frustum of rays, into tree.
338                Tests conservative using the bounding box of the nodes.
339                @returns number of view cells it intersected
340        */
341        int CastBeam(Beam &beam);
342
343        void CollectViewCells(BspNode *root,
344                                                  bool onlyValid,
345                                                  ViewCellContainer &viewCells,
346                                                  bool onlyUnmailed = false) const;
347
348       
349        int FindApproximateNeighbors(BspNode *n,
350                                                             vector<BspLeaf *> &neighbors,
351                                                                 const bool onlyUnmailed) const;
352
353        /** Checks if tree validity-flags are right
354                with respect to view cell valitiy.
355                If not, marks subtree as invalid.
356        */
357        void ValidateTree();
358
359        /** Invalid view cells are added to the unbounded space
360        */
361        void CollapseViewCells();
362
363        /** Collects rays stored in the leaves.
364        */
365        void CollectRays(VssRayContainer &rays);
366
367        /** Intersects box with the tree and returns the number of intersected boxes.
368                @returns number of view cells found
369        */
370        int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const;
371
372        // pointer to the hierarchy of view cells
373        ViewCellsTree *mViewCellsTree;
374
375
376protected:
377
378        // --------------------------------------------------------------
379        // For sorting objects
380        // --------------------------------------------------------------
381        struct SortableEntry
382        {
383                enum EType
384                {
385                        ERayMin,
386                        ERayMax
387                };
388
389                int type;
390                float value;
391                VssRay *ray;
392 
393                SortableEntry() {}
394                SortableEntry(const int t, const float v, VssRay *r):type(t),
395                                          value(v), ray(r)
396                {
397                }
398               
399                friend bool operator<(const SortableEntry &a, const SortableEntry &b)
400                {
401                        return a.value < b.value;
402                }
403        };
404
405        /** faster evaluation of split plane cost for kd axis aligned cells.
406        */
407        float EvalAxisAlignedSplitCost(const VspBspTraversalData &data,
408                                                                   const AxisAlignedBox3 &box,
409                                                                   const int axis,
410                                                                   const float &position,
411                                                                   float &pFront,
412                                                                   float &pBack) const;
413
414        /** Evaluates candidate for splitting.
415        */
416        void EvalSplitCandidate(VspBspTraversalData &tData, VspBspSplitCandidate &splitData);
417
418        /** Computes priority of the traversal data and stores it in tData.
419        */
420        void EvalPriority(VspBspTraversalData &tData) const;
421
422        float EvalRenderCostDecrease(const Plane3 &candidatePlane,
423                                                                 const VspBspTraversalData &data) const;
424
425        void ConstructWithSplitQueue(const PolygonContainer &polys, RayInfoContainer *rays);
426
427
428        /** Returns view cell corresponding to
429                the invalid view space. If it does not exist, it is created.
430        */
431        BspViewCell *GetOrCreateOutOfBoundsCell();
432
433        /** Collapses the tree with respect to the view cell partition,
434                i.e. leaves having the same view cell are collapsed.
435                @param node the root of the subtree to be collapsed
436                @param collapsed returns the number of collapsed nodes
437                @returns node of type leaf if the node could be collapsed,
438                this node otherwise
439        */
440        BspNode *CollapseTree(BspNode *node, int &collapsed);
441
442        /** Helper function revalidating the view cell leaf list after merge.
443        */
444        void RepairViewCellsLeafLists();
445
446        /** Evaluates tree stats in the BSP tree leafs.
447        */
448        void EvaluateLeafStats(const VspBspTraversalData &data);
449
450        /** Subdivides node with respect to the traversal data.
451            @param tStack current traversal stack
452                @param tData traversal data also holding node to be subdivided
453                @returns new root of the subtree
454        */
455        BspNode *Subdivide(VspBspTraversalQueue &tStack,
456                                           VspBspTraversalData &tData);
457
458        BspNode *Subdivide(VspBspSplitQueue &tQueue,
459                                           VspBspSplitCandidate &splitCandidate);
460
461        /** Constructs the tree from the given traversal data.
462                @param polys stores set of polygons on which subdivision may be based
463                @param rays storesset of rays on which subdivision may be based
464        */
465        void Construct(const PolygonContainer &polys, RayInfoContainer *rays);
466
467        /** Selects the best possible splitting plane.
468                @param plane returns the split plane
469                @param leaf the leaf to be split
470                @param polys the polygon list on which the split decition is based
471                @param rays ray container on which selection may be based
472                @note the polygons can be reordered in the process
473                @returns true if the cost of the split is under maxCostRatio
474
475        */
476        bool SelectPlane(Plane3 &plane,
477                                         BspLeaf *leaf,
478                                         VspBspTraversalData &data,
479                                         VspBspTraversalData &frontData,
480                                         VspBspTraversalData &backData,
481                                         int &splitAxis);
482       
483        /** Strategies where the effect of the split plane is tested
484            on all input rays.
485
486                @returns the cost of the candidate split plane
487        */
488        float EvalSplitPlaneCost(const Plane3 &candidatePlane,
489                                                         const VspBspTraversalData &data,
490                                                         BspNodeGeometry &geomFront,
491                                                         BspNodeGeometry &geomBack,
492                                                         float &pFront,
493                                                         float &pBack) const;
494
495        /** Subdivides leaf.
496                @param leaf the leaf to be subdivided
497               
498                @param polys the polygons to be split
499                @param frontPolys returns the polygons in front of the split plane
500                @param backPolys returns the polygons in the back of the split plane
501               
502                @param rays the polygons to be filtered
503                @param frontRays returns the polygons in front of the split plane
504                @param backRays returns the polygons in the back of the split plane
505
506                @returns the root of the subdivision
507        */
508
509        BspInterior *SubdivideNode(const Plane3 &splitPlane,
510                                                           VspBspTraversalData &tData,
511                                                           VspBspTraversalData &frontData,
512                               VspBspTraversalData &backData,
513                                                           PolygonContainer &coincident);
514
515        /** Extracts the meshes of the objects and adds them to polygons.
516                Adds object aabb to the aabb of the tree.
517                @param maxPolys the maximal number of objects to be stored as polygons
518                @returns the number of polygons
519        */
520        int AddToPolygonSoup(const ObjectContainer &objects,
521                                                 PolygonContainer &polys,
522                                                 int maxObjects = 0);
523
524        /** Extracts the meshes of the view cells and and adds them to polygons.
525                Adds view cell aabb to the aabb of the tree.
526                @param maxPolys the maximal number of objects to be stored as polygons
527                @returns the number of polygons
528        */
529        int AddToPolygonSoup(const ViewCellContainer &viewCells,
530                                                 PolygonContainer &polys,
531                                                 int maxObjects = 0);
532
533        /** Extract polygons of this mesh and add to polygon container.
534                @param mesh the mesh that drives the polygon construction
535                @param parent the parent intersectable this polygon is constructed from
536                @returns number of polygons
537        */
538        int AddMeshToPolygons(Mesh *mesh, PolygonContainer &polys, MeshInstance *parent);
539
540        /** Selects an axis aligned for the next split.
541                @returns cost for this split
542        */
543        float SelectAxisAlignedPlane(Plane3 &plane,
544                                                                 const VspBspTraversalData &tData,
545                                                                 int &axis,
546                                                                 BspNodeGeometry **frontGeom,
547                                                                 BspNodeGeometry **backGeom,
548                                                                 float &pFront,
549                                                                 float &pBack,
550                                                                 const bool useKdSplit);
551
552        /** Sorts split candidates for surface area heuristics for axis aligned splits.
553                @param polys the input for choosing split candidates
554                @param axis the current split axis
555                @param splitCandidates returns sorted list of split candidates
556        */
557        void SortSplitCandidates(const RayInfoContainer &rays,
558                                                         const int axis,
559                                                         float minBand,
560                                                         float maxBand);
561
562        /** Computes best cost for axis aligned planes.
563        */
564        float BestCostRatioHeuristics(const RayInfoContainer &rays,
565                                                                  const AxisAlignedBox3 &box,
566                                                                  const int pvsSize,
567                                                                  const int axis,
568                                                                  float &position);
569
570        /** Selects an axis aligned split plane.
571                @Returns true if split is valied
572        */
573        bool SelectAxisAlignedPlane(Plane3 &plane, const PolygonContainer &polys) const;
574
575        /** Subdivides the rays into front and back rays according to the split plane.
576               
577                @param plane the split plane
578                @param rays contains the rays to be split. The rays are
579                           distributed into front and back rays.
580                @param frontRays returns rays on the front side of the plane
581                @param backRays returns rays on the back side of the plane
582               
583                @returns the number of splits
584        */
585        int SplitRays(const Plane3 &plane,
586                                  RayInfoContainer &rays,
587                              RayInfoContainer &frontRays,
588                                  RayInfoContainer &backRays) const;
589
590
591        /** Extracts the split planes representing the space bounded by node n.
592        */
593        void ExtractHalfSpaces(BspNode *n, vector<Plane3> &halfSpaces) const;
594
595        /** Adds the object to the pvs of the front and back leaf with a given classification.
596
597                @param obj the object to be added
598                @param cf the ray classification regarding the split plane
599                @param frontPvs returns the PVS of the front partition
600                @param backPvs returns the PVS of the back partition
601       
602        */
603        void AddObjToPvs(Intersectable *obj,
604                                         const int cf,
605                                         float &frontPvs,
606                                         float &backPvs,
607                                         float &totalPvs) const;
608       
609        /** Computes PVS size induced by the rays.
610        */
611        int ComputePvsSize(const RayInfoContainer &rays) const;
612
613        /** Returns true if tree can be terminated.
614        */
615        inline bool LocalTerminationCriteriaMet(const VspBspTraversalData &data) const;
616
617        /** Returns true if global tree can be terminated.
618        */
619        inline bool GlobalTerminationCriteriaMet(const VspBspTraversalData &data) const;
620
621        /** Computes accumulated ray lenght of this rays.
622        */
623        float AccumulatedRayLength(const RayInfoContainer &rays) const;
624
625        /** Splits polygons with respect to the split plane.
626
627                @param plane the split plane
628                @param polys the polygons to be split. the polygons are consumed and
629                           distributed to the containers frontPolys, backPolys, coincident.
630                @param frontPolys returns the polygons in the front of the split plane
631                @param backPolys returns the polygons in the back of the split plane
632                @param coincident returns the polygons coincident to the split plane
633
634                @returns the number of splits   
635        */
636        int SplitPolygons(const Plane3 &plane,
637                                          PolygonContainer &polys,
638                                          PolygonContainer &frontPolys,
639                                          PolygonContainer &backPolys,
640                                          PolygonContainer &coincident) const;
641
642        /** Adds ray sample contributions to the PVS.
643                @param sampleContributions the number contributions of the samples
644                @param contributingSampels the number of contributing rays
645               
646        */
647        void AddToPvs(BspLeaf *leaf,
648                                  const RayInfoContainer &rays,
649                                  float &sampleContributions,
650                                  int &contributingSamples);
651
652
653
654
655
656       
657        /** Take 3 ray endpoints, where two are minimum and one a maximum
658                point or the other way round.
659        */
660        Plane3 ChooseCandidatePlane(const RayInfoContainer &rays) const;
661
662        /** Take plane normal as plane normal and the midpoint of the ray.
663                PROBLEM: does not resemble any point where visibility is
664                likely to change
665        */
666        Plane3 ChooseCandidatePlane2(const RayInfoContainer &rays) const;
667
668        /** Fit the plane between the two lines so that the plane
669                has equal shortest distance to both lines.
670        */
671        Plane3 ChooseCandidatePlane3(const RayInfoContainer &rays) const;
672 
673        /** Collects candidates for merging.
674                @param leaves the leaves to be merged
675                @returns number of leaves in queue
676        */
677        int CollectMergeCandidates(const vector<BspLeaf *> leaves, vector<MergeCandidate> &candidates);
678
679        /** Collects candidates for the merge in the merge queue.
680                @returns number of leaves in queue
681        */
682        int CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
683       
684        /** Preprocesses polygons and throws out all polygons which are coincident to
685                the view space box faces (they can be problematic).
686        */
687        void PreprocessPolygons(PolygonContainer &polys);
688       
689        /** Propagates valid flag up the tree.
690        */
691        void PropagateUpValidity(BspNode *node);
692
693        /** Writes the node to disk
694                @note: should be implemented as visitor
695        */
696  void ExportNode(BspNode *node, std::ofstream &stream);
697
698        /** Returns estimated memory usage of tree.
699        */
700        //float GetMemUsage(const VspBspTraversalQueue &tstack) const;
701        float GetMemUsage() const;
702
703
704
705        /// Pointer to the root of the tree
706        BspNode *mRoot;
707               
708        BspTreeStatistics mBspStats;
709
710        /// Strategies for choosing next split plane.
711        enum {NO_STRATEGY = 0,
712                  RANDOM_POLYGON = 1,
713                  AXIS_ALIGNED = 2,
714                  LEAST_RAY_SPLITS = 256,
715                  BALANCED_RAYS = 512,
716                  PVS = 1024
717                };
718
719        /// box around the whole view domain
720        AxisAlignedBox3 mBox;
721
722        bool mUseCostHeuristics;
723
724        /// minimal number of rays before subdivision termination
725        int mTermMinRays;
726        /// maximal possible depth
727        int mTermMaxDepth;
728        /// mininum probability
729        float mTermMinProbability;
730        /// mininum PVS
731        int mTermMinPvs;
732        /// maximal contribution per ray
733        float mTermMaxRayContribution;
734        /// minimal accumulated ray length
735        float mTermMinAccRayLength;
736
737        //HACK
738        int mTermMinPolygons;
739
740        float mTermMinGlobalCostRatio;
741        int mTermGlobalCostMissTolerance;
742
743        int mGlobalCostMisses;
744
745        bool mUseSplitCostQueue;
746        //-- termination criteria for axis aligned split
747
748        /// minimal number of rays for axis aligned split
749        int mTermMinRaysForAxisAligned;
750        // max ray contribution
751        float mTermMaxRayContriForAxisAligned;
752
753        /// strategy to get the best split plane
754        int mSplitPlaneStrategy;
755        /// number of candidates evaluated for the next split plane
756        int mMaxPolyCandidates;
757        /// number of candidates for split planes evaluated using the rays
758        int mMaxRayCandidates;
759        /// balancing factor for PVS criterium
760        float mCtDivCi;
761
762        //-- axis aligned split criteria
763        float mAxisAlignedCtDivCi;
764        /// spezifies the split border of the axis aligned split
765        float mAxisAlignedSplitBorder;
766
767        /// maximal acceptable cost ratio
768        float mTermMaxCostRatio;
769        /// tolerance value indicating how often the max cost ratio can be failed
770        int mTermMissTolerance;
771
772        //-- factors guiding the split plane heuristics
773        float mLeastRaySplitsFactor;
774        float mBalancedRaysFactor;
775        float mPvsFactor;
776
777        /// if area or volume should be used for PVS heuristics
778        bool mUseAreaForPvs;
779        /// tolerance for polygon split
780        float mEpsilon;
781        /// maximal number of test rays used to evaluate candidate split plane
782        int mMaxTests;
783        /// normalizes different bsp split plane criteria
784        float mCostNormalizer;
785        /// maximal number of view cells
786        int mMaxViewCells;
787       
788  std::ofstream  mSubdivisionStats;
789
790        // if rays should be stored in leaves
791        bool mStoreRays;
792       
793        /// if only driving axis should be used for split
794        bool mOnlyDrivingAxis;
795
796        ViewCellsManager *mViewCellsManager;
797
798        vector<SortableEntry> *mSplitCandidates;
799
800       
801        float mRenderCostWeight;
802        /// View cell corresponding to the space outside the valid view space
803        BspViewCell *mOutOfBoundsCell;
804
805        /// maximal tree memory
806        float mMaxMemory;
807        /// the tree is out of memory
808        bool mOutOfMemory;
809       
810        float mTotalCost;
811        int mTotalPvsSize;
812
813        float mMinBand;
814        float mMaxBand;
815
816        //int mSplits;
817        /// subdivision stats output file
818        std::ofstream mSubdivsionStats;
819        /// if random split axis should be used
820        bool mUseRandomAxis;
821        /// use polygon split whenever there are polys left
822        bool mUsePolygonSplitIfAvailable;
823        /// current time stamp (used for keeping split history)
824        int mTimeStamp;
825        /// number of currenly generated view cells
826        int mCreatedViewCells;
827        /// if vsp bsp tree should simulate octree
828        bool mCirculatingAxis;
829
830        /// if we should use breath first priority for the splits
831        int mNodePriorityQueueType;
832
833        // priority queue strategy
834        enum {BREATH_FIRST, DEPTH_FIRST, COST_BASED};
835
836
837private:
838
839        /// Generates unique ids for PVS criterium
840        static void GenerateUniqueIdsForPvs();
841
842        //-- unique ids for PVS criterium
843        static int sFrontId;
844        static int sBackId;
845        static int sFrontAndBackId;
846};
847
848}
849
850
851#endif
Note: See TracBrowser for help on using the repository browser.