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

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