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

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