source: GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h @ 860

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