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

Revision 810, 23.5 KB checked in by mattausch, 19 years ago (diff)

added from point visibility tree:
this tree is constructed using from point visibility information

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