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

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