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

Revision 1006, 23.2 KB checked in by mattausch, 19 years ago (diff)

started viewspace-objectspace subdivision
removed memory leaks

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