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

Revision 863, 23.4 KB checked in by mattausch, 18 years ago (diff)

working on preprocessor integration
added iv stuff

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