source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h @ 422

Revision 422, 22.3 KB checked in by mattausch, 19 years ago (diff)

worded on vspkdtree

Line 
1#ifndef _ViewCellBsp_H__
2#define _ViewCellBsp_H__
3
4#include "Mesh.h"
5#include "Containers.h"
6#include "Polygon3.h"
7#include <stack>
8#include "Statistics.h"
9
10class ViewCell;
11class BspViewCell;
12class Plane3;
13class BspTree; 
14class BspInterior;
15//class Polygon3;
16class AxisAlignedBox3;
17class Ray;
18
19class BspNodeGeometry
20{
21public:
22        BspNodeGeometry()
23        {}; 
24
25        ~BspNodeGeometry();
26
27        float GetArea() const;
28       
29        /** Computes new cell based on the old cell definition and a new split plane
30                @param side indicates which side of the halfspace
31        */
32        void SplitGeometry(BspNodeGeometry &front,
33                                           BspNodeGeometry &back,
34                                           const BspTree &tree,
35                                           const Plane3 &splitPlane) const;
36
37        Polygon3 *SplitPolygon(Polygon3 *poly, const BspTree &tree) const;
38
39        PolygonContainer mPolys;
40};
41
42/** Data structure used for optimized ray casting.
43*/
44struct BspRayTraversalData
45{
46    BspNode *mNode;
47    Vector3 mExitPoint;
48    float mMaxT;
49   
50    BspRayTraversalData() {}
51
52    BspRayTraversalData(BspNode *n, const Vector3 &extp, const float maxt):
53    mNode(n), mExitPoint(extp), mMaxT(maxt)
54        {}
55};
56
57/** Data used for passing ray data down the tree.
58*/
59struct BoundedRay
60{
61        Ray *mRay;
62        float mMinT;
63        float mMaxT;
64               
65        BoundedRay(): mMinT(0), mMaxT(1e6), mRay(NULL)
66        {}
67        BoundedRay(Ray *r, float minT, float maxT):
68        mRay(r), mMinT(minT), mMaxT(maxT)
69        {}
70};
71
72typedef vector<BoundedRay *> BoundedRayContainer;
73
74class BspTreeStatistics: public StatisticsBase
75{
76public:
77        // total number of nodes
78        int nodes;
79        // number of splits
80        int splits;
81        // totals number of rays
82        int rays;
83        // maximal reached depth
84        int maxDepth;
85        // minimal depth
86        int minDepth;
87        // max depth nodes
88        int maxDepthNodes;
89        // max number of rays per node
90        int maxObjectRefs;
91        // accumulated depth (used to compute average)
92        int accumDepth;
93        // number of initial polygons
94        int polys;
95        /// samples contributing to pvs
96        int contributingSamples;
97        /// sample contributions to pvs
98        int sampleContributions;
99        /// largest pvs
100        int largestPvs;
101
102        // Constructor
103        BspTreeStatistics()
104        {
105                Reset();
106        }
107
108        int Nodes() const {return nodes;}
109        int Interior() const { return nodes / 2; }
110        int Leaves() const { return (nodes / 2) + 1; }
111       
112        // TODO: computation wrong
113        double AvgDepth() const { return accumDepth / (double)Leaves();};
114 
115        void Reset()
116        {
117                nodes = 0;
118                splits = 0;
119                maxDepthNodes = 0;
120                maxDepth = 0;
121                minDepth = 99999;
122                polys = 0;
123                accumDepth = 0;
124       
125                contributingSamples = 0;
126                sampleContributions = 0;
127        }
128
129        void Print(ostream &app) const;
130
131        friend ostream &operator<<(ostream &s, const BspTreeStatistics &stat)
132        {
133                stat.Print(s);
134                return s;
135        }
136};
137
138class BspViewCellsStatistics: public StatisticsBase
139{
140public:
141
142        /// number of view cells
143        int viewCells;
144
145        /// size of the PVS
146        int pvs;
147 
148        /// largest PVS of all view cells
149        int maxPvs;
150
151        /// smallest PVS of all view cells
152        int minPvs;
153
154        /// view cells with empty PVS
155        int emptyPvs;
156
157        /// number of bsp leaves covering the view space
158        int bspLeaves;
159
160        /// largest number of leaves covered by one view cell 
161        int maxBspLeaves;
162
163    // Constructor
164        BspViewCellsStatistics()
165        {
166                Reset();
167        }
168
169        double AvgBspLeaves() const {return (double)bspLeaves / (double)viewCells;};
170        double AvgPvs() const {return (double)pvs / (double)viewCells;};
171 
172        void Reset()
173        {
174                viewCells = 0; 
175                pvs = 0; 
176                maxPvs = 0;
177
178                minPvs = 999999;
179                emptyPvs = 0;
180                bspLeaves = 0;
181                maxBspLeaves = 0;
182        }
183
184        void Print(ostream &app) const;
185
186        friend ostream &operator<<(ostream &s, const BspViewCellsStatistics &stat)
187        {
188                stat.Print(s);
189                return s;
190        } 
191};
192
193/**
194    BspNode abstract class serving for interior and leaf node implementation
195*/
196class BspNode
197{
198        friend class BspTree;
199
200public:
201        BspNode();
202        virtual ~BspNode(){};
203        BspNode(BspInterior *parent);
204
205        /** Determines whether this node is a leaf or not
206        @return true if leaf
207        */
208        virtual bool IsLeaf() const = 0;
209
210        /** Determines whether this node is a root
211        @return true if root
212        */
213        virtual bool IsRoot() const;
214
215        /** Returns parent node.
216        */
217        BspInterior *GetParent();
218
219        /** Sets parent node.
220        */
221        void SetParent(BspInterior *parent);
222
223       
224        static int sMailId;
225        int mMailbox;
226 
227        void Mail() { mMailbox = sMailId; }
228        static void NewMail() { ++ sMailId; }
229        bool Mailed() const { return mMailbox == sMailId; }
230
231protected:
232
233        /// parent of this node
234        BspInterior *mParent;
235};
236
237/** BSP interior node implementation
238*/
239class BspInterior : public BspNode
240{
241        friend class BspTree;
242public:
243        /** Standard contructor taking split plane as argument.
244        */
245        BspInterior(const Plane3 &plane);
246        ~BspInterior();
247        /** @return false since it is an interior node
248        */
249        bool IsLeaf() const;
250
251        BspNode *GetBack();
252        BspNode *GetFront();
253
254        Plane3 *GetPlane();
255
256        void ReplaceChildLink(BspNode *oldChild, BspNode *newChild);
257        void SetupChildLinks(BspNode *b, BspNode *f);
258
259        /** Splits polygons with respect to the split plane.
260                @param polys the polygons to be split. the polygons are consumed and
261                           distributed to the containers frontPolys, backPolys, coincident.
262                @param frontPolys returns the polygons in the front of the split plane
263                @param backPolys returns the polygons in the back of the split plane
264                @param coincident returns the polygons coincident to the split plane
265
266                @returns the number of splits   
267        */
268        int SplitPolygons(PolygonContainer &polys,
269                                          PolygonContainer &frontPolys,
270                                          PolygonContainer &backPolys,
271                                          PolygonContainer &coincident);
272
273        friend ostream &operator<<(ostream &s, const BspInterior &A)
274        {
275                return s << A.mPlane;
276        }
277
278protected:
279
280        /// Splitting plane corresponding to this node
281        Plane3 mPlane;
282        /// back node
283        BspNode *mBack;
284        /// front node
285        BspNode *mFront;
286};
287
288/** BSP leaf node implementation.
289*/
290class BspLeaf : public BspNode
291{
292        friend class BspTree;
293
294public:
295        BspLeaf();
296        BspLeaf(BspViewCell *viewCell);
297        BspLeaf(BspInterior *parent);
298        BspLeaf(BspInterior *parent, BspViewCell *viewCell);
299
300        /** @return true since it is an interior node
301        */
302        bool IsLeaf() const;
303       
304        /** Returns pointer of view cell.
305        */
306        BspViewCell *GetViewCell() const;
307
308        /** Sets pointer to view cell.
309        */
310        void SetViewCell(BspViewCell *viewCell);
311
312        /** Adds rays to the PVS.
313                @param sampleContributions the number contributions of the sampels
314                @param contributingSampels the number of contributing rays
315               
316        */
317        void AddToPvs(const BoundedRayContainer &rays, int &sampleContributions,
318                                  int &contributingSamples, bool storeLeavesWithRays = false);
319
320protected:
321
322        /// if NULL this does not correspond to feasible viewcell
323        BspViewCell *mViewCell;
324};
325
326/** Implementation of the view cell BSP tree.
327*/
328class BspTree
329{
330public:
331       
332        /** Additional data which is passed down the BSP tree during traversal.
333        */
334        struct BspTraversalData
335        { 
336                /// the current node
337                BspNode *mNode;
338                /// polygonal data for splitting
339                PolygonContainer *mPolygons;
340                /// current depth
341                int mDepth;
342                /// the view cell associated with this subdivsion
343                ViewCell *mViewCell;
344                /// rays piercing this node
345                BoundedRayContainer *mRays;
346                /// area of current node
347                float mArea;
348                BspNodeGeometry *mGeometry;
349
350                /// pvs size
351                int mPvs;
352               
353                BspTraversalData():
354                mNode(NULL),
355                mPolygons(NULL),
356                mDepth(0),
357                mViewCell(NULL),
358                mRays(NULL),
359                mPvs(0),
360                mArea(0.0),
361                mGeometry(NULL)
362                {}
363               
364                BspTraversalData(BspNode *node,
365                                                 PolygonContainer *polys,
366                                                 const int depth,
367                                                 ViewCell *viewCell,
368                                                 BoundedRayContainer *rays,
369                                                 int pvs,
370                                                 float area,
371                                                 BspNodeGeometry *cell):
372                mNode(node),
373                mPolygons(polys),
374                mDepth(depth),
375                mViewCell(viewCell),
376                mRays(rays),
377                mPvs(pvs),
378                mArea(area),
379                mGeometry(cell)
380                {}
381    };
382       
383        typedef std::stack<BspTraversalData> BspTraversalStack;
384
385        /** Default constructor creating an empty tree.
386                @param viewCell view cell corresponding to unbounded space
387        */
388        BspTree(BspViewCell *viewCell);
389
390        ~BspTree();
391
392        const BspTreeStatistics &GetStatistics() const;
393 
394        /** Constructs tree using the given list of view cells.
395            For this type of construction we filter all view cells down the
396                tree. If there is no polygon left, the last split plane
397            decides inside or outside of the viewcell. A pointer to the
398                appropriate view cell is stored within each leaf.
399                Many leafs can point to the same viewcell.
400        */
401        void Construct(const ViewCellContainer &viewCells);
402
403        /** Constructs tree using the given list of objects.
404            @note the objects are not taken as view cells, but the view cells are
405                constructed from the subdivision: Each leaf is taken as one viewcell.
406                @param objects list of objects
407        */
408        void Construct(const ObjectContainer &objects);
409
410        /** Constructs the tree from a given set of rays.
411                @param sampleRays the set of sample rays the construction is based on
412                @param viewCells if not NULL, new view cells are
413                created in the leafs and stored in the conatainer
414        */
415        void Construct(const RayContainer &sampleRays);
416
417        /** Returns list of BSP leaves.
418        */
419        void CollectLeaves(vector<BspLeaf *> &leaves) const;
420
421        /** Returns box which bounds the whole tree.
422        */
423        AxisAlignedBox3 GetBoundingBox()const;
424
425        /** Returns root of BSP tree.
426        */
427        BspNode *GetRoot() const;
428
429        /** Exports Bsp tree to file.
430        */
431        bool Export(const string filename);
432
433        /** Collects the leaf view cells of the tree
434                @param viewCells returns the view cells
435        */
436        void CollectViewCells(ViewCellContainer &viewCells) const;
437
438        /** A ray is cast possible intersecting the tree.
439                @param the ray that is cast.
440                @returns the number of intersections with objects stored in the tree.
441        */
442        int CastRay(Ray &ray);
443
444        /** Set to true if new view cells shall be generated in each leaf.
445        */
446        void SetGenerateViewCells(int generateViewCells);
447
448        /// bsp tree construction types
449        enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_SAMPLES};
450
451        /** Returns statistics.
452        */
453        BspTreeStatistics &GetStat();
454
455        /** finds neighbouring leaves of this tree node.
456        */
457        int FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors,
458                                          const bool onlyUnmailed) const;
459
460        /** Constructs geometry associated with the half space intersections
461                leading to this node.
462        */
463        void ConstructGeometry(BspNode *n, PolygonContainer &cell) const;
464       
465        /** Construct geometry of view cell.
466        */
467        void ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const;
468
469        void ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const;
470
471        /** Returns random leaf of BSP tree.
472                @param halfspace defines the halfspace from which the leaf is taken.
473        */
474        BspLeaf *GetRandomLeaf(const Plane3 &halfspace);
475
476        /** Returns random leaf of BSP tree.
477                @param onlyUnmailed if only unmailed leaves should be returned.
478        */
479        BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false);
480
481        /** Returns true if merge criteria are reached.
482        */
483    bool ShouldMerge(BspLeaf *front, BspLeaf *back) const;
484
485        /** Merges view cells based on some criteria
486            E.g., empty view cells can pe purged, view cells which have
487                a very similar PVS can be merged to one larger view cell.
488
489                @returns true if merge was successful.
490        */
491        bool MergeViewCells(BspLeaf *front, BspLeaf *back) const;
492
493        /** Traverses tree and counts all view cells as well as their PVS size.
494        */
495        void EvaluateViewCellsStats(BspViewCellsStatistics &stat) const;
496
497        /** Parses the environment and stores the global BSP tree parameters
498        */
499        static void ParseEnvironment();
500
501        /// BSP tree construction method
502        static int sConstructionMethod;
503
504
505protected:
506
507        // --------------------------------------------------------------
508        // For sorting objects
509        // --------------------------------------------------------------
510        struct SortableEntry
511        {
512                enum {POLY_MIN, POLY_MAX};
513   
514                int type;
515                float value;
516                Polygon3 *poly;
517                SortableEntry() {}
518                SortableEntry(const int t, const float v, Polygon3 *poly):
519                type(t), value(v), poly(poly) {}
520               
521                bool operator<(const SortableEntry &b) const
522                {
523                        return value < b.value;
524                } 
525        };
526
527        /** Evaluates tree stats in the BSP tree leafs.
528        */
529        void EvaluateLeafStats(const BspTraversalData &data);
530
531        /** Subdivides node with respect to the traversal data.
532            @param tStack current traversal stack
533                @param tData traversal data also holding node to be subdivided
534                @returns new root of the subtree
535        */
536        BspNode *Subdivide(BspTraversalStack &tStack, BspTraversalData &tData);
537
538        /** Constructs the tree from the given list of polygons and rays.
539                @param polys stores set of polygons on which subdivision may be based
540                @param rays storesset of rays on which subdivision may be based
541        */
542        void Construct(PolygonContainer *polys, BoundedRayContainer *rays);
543
544        /** Selects the best possible splitting plane.
545                @param leaf the leaf to be split
546                @param polys the polygon list on which the split decition is based
547                @param rays ray container on which selection may be based
548                @note the polygons can be reordered in the process
549                @returns the split plane
550        */
551        Plane3 SelectPlane(BspLeaf *leaf,
552                                           BspTraversalData &data);
553
554        /** Evaluates the contribution of the candidate split plane.
555               
556                @param candidatePlane the candidate split plane
557                @param polys the polygons the split can be based on
558                @param rays the rays the split can be based on
559
560                @returns the cost of the candidate split plane
561        */
562        float SplitPlaneCost(const Plane3 &candidatePlane,
563                                                 BspTraversalData &data) const;
564
565        /** Strategies where the effect of the split plane is tested
566            on all input rays.
567                @returns the cost of the candidate split plane
568        */
569        float SplitPlaneCost(const Plane3 &candidatePlane,
570                                                 const PolygonContainer &polys) const;
571
572        /** Strategies where the effect of the split plane is tested
573            on all input rays.
574
575                @returns the cost of the candidate split plane
576        */
577        float SplitPlaneCost(const Plane3 &candidatePlane,
578                                                 const BoundedRayContainer &rays,
579                                                 const int pvs,
580                                                 const float area,
581                                                 const BspNodeGeometry &cell) const;
582
583        /** Filters next view cell down the tree and inserts it into the appropriate leaves
584                (i.e., possibly more than one leaf).
585        */
586        void InsertViewCell(ViewCell *viewCell);
587        /** Inserts polygons down the tree. The polygons are filtered until a leaf is reached,
588                then further subdivided.
589        */
590        void InsertPolygons(PolygonContainer *polys);
591
592        /** Subdivide leaf.
593                @param leaf the leaf to be subdivided
594               
595                @param polys the polygons to be split
596                @param frontPolys returns the polygons in front of the split plane
597                @param backPolys returns the polygons in the back of the split plane
598               
599                @param rays the polygons to be filtered
600                @param frontRays returns the polygons in front of the split plane
601                @param backRays returns the polygons in the back of the split plane
602
603                @returns the root of the subdivision
604        */
605
606        BspInterior *SubdivideNode(BspTraversalData &tData,
607                                                           BspTraversalData &frontData,
608                                                           BspTraversalData &backData,
609                                                           PolygonContainer &coincident);
610
611        /** Filters polygons down the tree.
612                @param node the current BSP node
613                @param polys the polygons to be filtered
614                @param frontPolys returns the polygons in front of the split plane
615                @param backPolys returns the polygons in the back of the split plane
616        */
617        void FilterPolygons(BspInterior *node,
618                                                PolygonContainer *polys,
619                                                PolygonContainer *frontPolys,
620                                                PolygonContainer *backPolys);
621
622        /** Selects the split plane in order to construct a tree with
623                certain characteristics (e.g., balanced tree, least splits,
624                2.5d aligned)
625                @param polygons container of polygons
626                @param rays bundle of rays on which the split can be based
627        */
628        Plane3 SelectPlaneHeuristics(BspLeaf *leaf,
629                                                                 BspTraversalData &data);
630
631        /** Extracts the meshes of the objects and adds them to polygons.
632                Adds object aabb to the aabb of the tree.
633                @param maxPolys the maximal number of objects to be stored as polygons
634                @returns the number of polygons
635        */
636        int AddToPolygonSoup(const ObjectContainer &objects,
637                                                 PolygonContainer &polys,
638                                                 int maxObjects = 0);
639
640        /** Extracts the meshes of the view cells and and adds them to polygons.
641                Adds view cell aabb to the aabb of the tree.
642                @param maxPolys the maximal number of objects to be stored as polygons
643                @returns the number of polygons
644        */
645        int AddToPolygonSoup(const ViewCellContainer &viewCells,
646                                                 PolygonContainer &polys,
647                                                 int maxObjects = 0);
648
649        /** Extract polygons of this mesh and add to polygon container.
650                @param mesh the mesh that drives the polygon construction
651                @param parent the parent intersectable this polygon is constructed from
652                @returns number of polygons
653        */
654        int AddMeshToPolygons(Mesh *mesh, PolygonContainer &polys, MeshInstance *parent);
655
656        /** returns next candidate index and reorders polygons so no candidate is chosen two times
657                @param the current candidate index
658                @param max the range of candidates
659        */
660        int GetNextCandidateIdx(int currentIdx, PolygonContainer &polys);
661
662        /** Helper function which extracts a view cell on the front and the back
663                of the split plane.
664                @param backViewCell returns view cell on the back of the split plane
665                @param frontViewCell returns a view cell on the front of the split plane
666                @param coincident container of polygons coincident to the split plane
667                @param splitPlane the split plane which decides about back and front
668                @param extractBack if a back view cell is extracted
669                @param extractFront if a front view cell is extracted
670        */
671        void ExtractViewCells(BspTraversalData &frontData,
672                                                  BspTraversalData &backData,
673                                                  const PolygonContainer &coincident,
674                                                  const Plane3 splitPlane) const;
675       
676        /** Computes best cost ratio for the suface area heuristics for axis aligned
677                splits. This heuristics minimizes the cost for ray traversal.
678                @param polys the polygons guiding the ratio computation
679                @param box the bounding box of the leaf
680                @param axis the current split axis
681                @param position returns the split position
682                @param objectsBack the number of objects in the back of the split plane
683                @param objectsFront the number of objects in the front of the split plane
684        */
685        float BestCostRatio(const PolygonContainer &polys,
686                                                const AxisAlignedBox3 &box,
687                                                const int axis,
688                                                float &position,
689                                                int &objectsBack,
690                                                int &objectsFront) const;
691       
692        /** Sorts split candidates for surface area heuristics for axis aligned splits.
693                @param polys the input for choosing split candidates
694                @param axis the current split axis
695                @param splitCandidates returns sorted list of split candidates
696        */
697        void SortSplitCandidates(const PolygonContainer &polys,
698                                                         const int axis,
699                                                         vector<SortableEntry> &splitCandidates) const;
700
701        /** Selects an axis aligned split plane.
702                Returns true if split is valied
703        */
704        bool SelectAxisAlignedPlane(Plane3 &plane, const PolygonContainer &polys) const;
705
706        /** Bounds ray and returns minT and maxT.
707                @returns true if ray hits BSP tree bounding box
708        */
709        bool BoundRay(const Ray &ray, float &minT, float &maxT) const;
710
711        /** Subdivides the rays into front and back rays according to the split plane.
712               
713                @param plane the split plane
714                @param rays contains the rays to be split. The rays are
715                           distributed into front and back rays.
716                @param frontRays returns rays on the front side of the plane
717                @param backRays returns rays on the back side of the plane
718               
719                @returns the number of splits
720        */
721        int SplitRays(const Plane3 &plane,
722                                  BoundedRayContainer &rays,
723                              BoundedRayContainer &frontRays,
724                                  BoundedRayContainer &backRays);
725
726
727        /** Extracts the split planes representing the space bounded by node n.
728        */
729        void ExtractHalfSpaces(BspNode *n, vector<Plane3> &halfSpaces) const;
730
731        /** Computes the pvs of the front and back leaf with a given classification.
732        */
733        void IncPvs(Intersectable &obj,
734                                  int &frontPvs,
735                                  int &backPvs,
736                                  const int cf,
737                                  const int frontId,
738                                  const int backId,
739                                  const int frontAndBackId) const;
740       
741        int ComputePvsSize(const BoundedRayContainer &rays) const;
742
743        inline bool TerminationCriteriaMet(const BspTraversalData &data) const;
744
745        float AccumulatedRayLength(BoundedRayContainer &rays) const;
746
747        /// Pointer to the root of the tree
748        BspNode *mRoot;
749               
750        BspTreeStatistics mStat;
751
752        /// Strategies for choosing next split plane.
753        enum {NO_STRATEGY = 0,
754                  RANDOM_POLYGON = 1,
755                  AXIS_ALIGNED = 2,
756                  LEAST_SPLITS = 4,
757                  BALANCED_POLYS = 8,
758                  BALANCED_VIEW_CELLS = 16,
759                  LARGEST_POLY_AREA = 32,
760                  VERTICAL_AXIS = 64,
761                  BLOCKED_RAYS = 128,
762                  LEAST_RAY_SPLITS = 256,
763                  BALANCED_RAYS = 512,
764                  PVS = 1024
765                };
766
767        /// box around the whole view domain
768        AxisAlignedBox3 mBox;
769
770        /// view cell corresponding to unbounded space
771        BspViewCell *mRootCell;
772
773        /// should view cells be stored or generated in the leaves?
774        bool mGenerateViewCells;
775
776        /// maximal number of polygons before subdivision termination
777        int mTermMaxPolygons;
778        /// maximal number of rays before subdivision termination
779        int mTermMaxRays;
780        /// maximal possible depth
781        int mTermMaxDepth;
782        /// mininum area
783        float mTermMinArea;
784        /// mininum PVS
785        int mTermMinPvs;
786        /// strategy to get the best split plane
787        int mSplitPlaneStrategy;
788        /// number of candidates evaluated for the next split plane
789        int mMaxPolyCandidates;
790        /// number of candidates for split planes evaluated using the rays
791        int mMaxRayCandidates;
792       
793        /// maximal number of polygons for axis aligned split
794        int mTermMaxPolysForAxisAligned;
795        /// maximal number of rays for axis aligned split
796        int mTermMaxRaysForAxisAligned;
797        /// maximal number of objects for axis aligned split
798        int mTermMaxObjectsForAxisAligned;
799        /// maximal contribution per ray
800        float mTermMaxRayContribution;
801        /// maximal accumulated ray length
802        float mTermMaxAccRayLength;
803
804        bool mStoreLeavesWithRays;
805
806        /// axis aligned split criteria
807        float mCtDivCi;
808        float mSplitBorder;
809        float mMaxCostRatio;
810
811        // factors guiding the split plane heuristics
812        float mLeastSplitsFactor;
813        float mBalancedPolysFactor;
814        float mBalancedViewCellsFactor;
815        float mVerticalSplitsFactor;
816        float mLargestPolyAreaFactor;
817        float mBlockedRaysFactor;
818        float mLeastRaySplitsFactor;
819        float mBalancedRaysFactor;
820        float mPvsFactor;
821
822        //-- thresholds used for view cells merge
823        int mMinPvsDif;
824        int mMinPvs;
825        int mMaxPvs;
826        /// if area or accumulated ray lenght should be used for PVS heuristics
827        bool mPvsUseArea;
828
829private:
830        /** Evaluates split plane classification with respect to the plane's
831                contribution for a balanced tree.
832        */
833        static const float sLeastPolySplitsTable[4];
834        /** Evaluates split plane classification with respect to the plane's
835                contribution for a minimum number splits in the tree.
836        */
837        static const float sBalancedPolysTable[4];
838        /** Evaluates split plane classification with respect to the plane's
839                contribution for a minimum number of ray splits.
840        */
841        static const float sLeastRaySplitsTable[5];
842        /** Evaluates split plane classification with respect to the plane's
843                contribution for balanced rays.
844        */
845        static const float sBalancedRaysTable[5];
846
847};
848
849#endif
Note: See TracBrowser for help on using the repository browser.