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

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