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

Revision 424, 22.5 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        // 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                /** Returns average ray contribution.
354                */
355                float GetAvgRayContribution() const
356                {
357                        return (float)mPvs / ((float)mRays->size() + Limits::Small);
358                }
359
360
361                BspTraversalData():
362                mNode(NULL),
363                mPolygons(NULL),
364                mDepth(0),
365                mViewCell(NULL),
366                mRays(NULL),
367                mPvs(0),
368                mArea(0.0),
369                mGeometry(NULL)
370                {}
371               
372                BspTraversalData(BspNode *node,
373                                                 PolygonContainer *polys,
374                                                 const int depth,
375                                                 ViewCell *viewCell,
376                                                 BoundedRayContainer *rays,
377                                                 int pvs,
378                                                 float area,
379                                                 BspNodeGeometry *cell):
380                mNode(node),
381                mPolygons(polys),
382                mDepth(depth),
383                mViewCell(viewCell),
384                mRays(rays),
385                mPvs(pvs),
386                mArea(area),
387                mGeometry(cell)
388                {}
389    };
390       
391        typedef std::stack<BspTraversalData> BspTraversalStack;
392
393        /** Default constructor creating an empty tree.
394                @param viewCell view cell corresponding to unbounded space
395        */
396        BspTree(BspViewCell *viewCell);
397
398        ~BspTree();
399
400        const BspTreeStatistics &GetStatistics() const;
401 
402        /** Constructs tree using the given list of view cells.
403            For this type of construction we filter all view cells down the
404                tree. If there is no polygon left, the last split plane
405            decides inside or outside of the viewcell. A pointer to the
406                appropriate view cell is stored within each leaf.
407                Many leafs can point to the same viewcell.
408        */
409        void Construct(const ViewCellContainer &viewCells);
410
411        /** Constructs tree using the given list of objects.
412            @note the objects are not taken as view cells, but the view cells are
413                constructed from the subdivision: Each leaf is taken as one viewcell.
414                @param objects list of objects
415        */
416        void Construct(const ObjectContainer &objects);
417
418        /** Constructs the tree from a given set of rays.
419                @param sampleRays the set of sample rays the construction is based on
420                @param viewCells if not NULL, new view cells are
421                created in the leafs and stored in the conatainer
422        */
423        void Construct(const RayContainer &sampleRays);
424
425        /** Returns list of BSP leaves.
426        */
427        void CollectLeaves(vector<BspLeaf *> &leaves) const;
428
429        /** Returns box which bounds the whole tree.
430        */
431        AxisAlignedBox3 GetBoundingBox()const;
432
433        /** Returns root of BSP tree.
434        */
435        BspNode *GetRoot() const;
436
437        /** Exports Bsp tree to file.
438        */
439        bool Export(const string filename);
440
441        /** Collects the leaf view cells of the tree
442                @param viewCells returns the view cells
443        */
444        void CollectViewCells(ViewCellContainer &viewCells) const;
445
446        /** A ray is cast possible intersecting the tree.
447                @param the ray that is cast.
448                @returns the number of intersections with objects stored in the tree.
449        */
450        int CastRay(Ray &ray);
451
452        /** Set to true if new view cells shall be generated in each leaf.
453        */
454        void SetGenerateViewCells(int generateViewCells);
455
456        /// bsp tree construction types
457        enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_SAMPLES};
458
459        /** Returns statistics.
460        */
461        BspTreeStatistics &GetStat();
462
463        /** finds neighbouring leaves of this tree node.
464        */
465        int FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors,
466                                          const bool onlyUnmailed) const;
467
468        /** Constructs geometry associated with the half space intersections
469                leading to this node.
470        */
471        void ConstructGeometry(BspNode *n, PolygonContainer &cell) const;
472       
473        /** Construct geometry of view cell.
474        */
475        void ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const;
476
477        void ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const;
478
479        /** Returns random leaf of BSP tree.
480                @param halfspace defines the halfspace from which the leaf is taken.
481        */
482        BspLeaf *GetRandomLeaf(const Plane3 &halfspace);
483
484        /** Returns random leaf of BSP tree.
485                @param onlyUnmailed if only unmailed leaves should be returned.
486        */
487        BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false);
488
489        /** Returns true if merge criteria are reached.
490        */
491    bool ShouldMerge(BspLeaf *front, BspLeaf *back) const;
492
493        /** Merges view cells based on some criteria
494            E.g., empty view cells can pe purged, view cells which have
495                a very similar PVS can be merged to one larger view cell.
496
497                @returns true if merge was successful.
498        */
499        bool MergeViewCells(BspLeaf *front, BspLeaf *back) const;
500
501        /** Traverses tree and counts all view cells as well as their PVS size.
502        */
503        void EvaluateViewCellsStats(BspViewCellsStatistics &stat) const;
504
505        /** Parses the environment and stores the global BSP tree parameters
506        */
507        static void ParseEnvironment();
508
509        /// BSP tree construction method
510        static int sConstructionMethod;
511
512
513protected:
514
515        // --------------------------------------------------------------
516        // For sorting objects
517        // --------------------------------------------------------------
518        struct SortableEntry
519        {
520                enum {POLY_MIN, POLY_MAX};
521   
522                int type;
523                float value;
524                Polygon3 *poly;
525                SortableEntry() {}
526                SortableEntry(const int t, const float v, Polygon3 *poly):
527                type(t), value(v), poly(poly) {}
528               
529                bool operator<(const SortableEntry &b) const
530                {
531                        return value < b.value;
532                } 
533        };
534
535        /** Evaluates tree stats in the BSP tree leafs.
536        */
537        void EvaluateLeafStats(const BspTraversalData &data);
538
539        /** Subdivides node with respect to the traversal data.
540            @param tStack current traversal stack
541                @param tData traversal data also holding node to be subdivided
542                @returns new root of the subtree
543        */
544        BspNode *Subdivide(BspTraversalStack &tStack, BspTraversalData &tData);
545
546        /** Constructs the tree from the given list of polygons and rays.
547                @param polys stores set of polygons on which subdivision may be based
548                @param rays storesset of rays on which subdivision may be based
549        */
550        void Construct(PolygonContainer *polys, BoundedRayContainer *rays);
551
552        /** Selects the best possible splitting plane.
553                @param leaf the leaf to be split
554                @param polys the polygon list on which the split decition is based
555                @param rays ray container on which selection may be based
556                @note the polygons can be reordered in the process
557                @returns the split plane
558        */
559        Plane3 SelectPlane(BspLeaf *leaf,
560                                           BspTraversalData &data);
561
562        /** Evaluates the contribution of the candidate split plane.
563               
564                @param candidatePlane the candidate split plane
565                @param polys the polygons the split can be based on
566                @param rays the rays the split can be based on
567
568                @returns the cost of the candidate split plane
569        */
570        float SplitPlaneCost(const Plane3 &candidatePlane,
571                                                 BspTraversalData &data) const;
572
573        /** Strategies where the effect of the split plane is tested
574            on all input rays.
575                @returns the cost of the candidate split plane
576        */
577        float SplitPlaneCost(const Plane3 &candidatePlane,
578                                                 const PolygonContainer &polys) const;
579
580        /** Strategies where the effect of the split plane is tested
581            on all input rays.
582
583                @returns the cost of the candidate split plane
584        */
585        float SplitPlaneCost(const Plane3 &candidatePlane,
586                                                 const BoundedRayContainer &rays,
587                                                 const int pvs,
588                                                 const float area,
589                                                 const BspNodeGeometry &cell) const;
590
591        /** Filters next view cell down the tree and inserts it into the appropriate leaves
592                (i.e., possibly more than one leaf).
593        */
594        void InsertViewCell(ViewCell *viewCell);
595        /** Inserts polygons down the tree. The polygons are filtered until a leaf is reached,
596                then further subdivided.
597        */
598        void InsertPolygons(PolygonContainer *polys);
599
600        /** Subdivide leaf.
601                @param leaf the leaf to be subdivided
602               
603                @param polys the polygons to be split
604                @param frontPolys returns the polygons in front of the split plane
605                @param backPolys returns the polygons in the back of the split plane
606               
607                @param rays the polygons to be filtered
608                @param frontRays returns the polygons in front of the split plane
609                @param backRays returns the polygons in the back of the split plane
610
611                @returns the root of the subdivision
612        */
613
614        BspInterior *SubdivideNode(BspTraversalData &tData,
615                                                           BspTraversalData &frontData,
616                                                           BspTraversalData &backData,
617                                                           PolygonContainer &coincident);
618
619        /** Filters polygons down the tree.
620                @param node the current BSP node
621                @param polys the polygons to be filtered
622                @param frontPolys returns the polygons in front of the split plane
623                @param backPolys returns the polygons in the back of the split plane
624        */
625        void FilterPolygons(BspInterior *node,
626                                                PolygonContainer *polys,
627                                                PolygonContainer *frontPolys,
628                                                PolygonContainer *backPolys);
629
630        /** Selects the split plane in order to construct a tree with
631                certain characteristics (e.g., balanced tree, least splits,
632                2.5d aligned)
633                @param polygons container of polygons
634                @param rays bundle of rays on which the split can be based
635        */
636        Plane3 SelectPlaneHeuristics(BspLeaf *leaf,
637                                                                 BspTraversalData &data);
638
639        /** Extracts the meshes of the objects and adds them to polygons.
640                Adds object aabb to the aabb of the tree.
641                @param maxPolys the maximal number of objects to be stored as polygons
642                @returns the number of polygons
643        */
644        int AddToPolygonSoup(const ObjectContainer &objects,
645                                                 PolygonContainer &polys,
646                                                 int maxObjects = 0);
647
648        /** Extracts the meshes of the view cells and and adds them to polygons.
649                Adds view cell aabb to the aabb of the tree.
650                @param maxPolys the maximal number of objects to be stored as polygons
651                @returns the number of polygons
652        */
653        int AddToPolygonSoup(const ViewCellContainer &viewCells,
654                                                 PolygonContainer &polys,
655                                                 int maxObjects = 0);
656
657        /** Extract polygons of this mesh and add to polygon container.
658                @param mesh the mesh that drives the polygon construction
659                @param parent the parent intersectable this polygon is constructed from
660                @returns number of polygons
661        */
662        int AddMeshToPolygons(Mesh *mesh, PolygonContainer &polys, MeshInstance *parent);
663
664        /** returns next candidate index and reorders polygons so no candidate is chosen two times
665                @param the current candidate index
666                @param max the range of candidates
667        */
668        int GetNextCandidateIdx(int currentIdx, PolygonContainer &polys);
669
670        /** Helper function which extracts a view cell on the front and the back
671                of the split plane.
672                @param backViewCell returns view cell on the back of the split plane
673                @param frontViewCell returns a view cell on the front of the split plane
674                @param coincident container of polygons coincident to the split plane
675                @param splitPlane the split plane which decides about back and front
676                @param extractBack if a back view cell is extracted
677                @param extractFront if a front view cell is extracted
678        */
679        void ExtractViewCells(BspTraversalData &frontData,
680                                                  BspTraversalData &backData,
681                                                  const PolygonContainer &coincident,
682                                                  const Plane3 splitPlane) const;
683       
684        /** Computes best cost ratio for the suface area heuristics for axis aligned
685                splits. This heuristics minimizes the cost for ray traversal.
686                @param polys the polygons guiding the ratio computation
687                @param box the bounding box of the leaf
688                @param axis the current split axis
689                @param position returns the split position
690                @param objectsBack the number of objects in the back of the split plane
691                @param objectsFront the number of objects in the front of the split plane
692        */
693        float BestCostRatio(const PolygonContainer &polys,
694                                                const AxisAlignedBox3 &box,
695                                                const int axis,
696                                                float &position,
697                                                int &objectsBack,
698                                                int &objectsFront) const;
699       
700        /** Sorts split candidates for surface area heuristics for axis aligned splits.
701                @param polys the input for choosing split candidates
702                @param axis the current split axis
703                @param splitCandidates returns sorted list of split candidates
704        */
705        void SortSplitCandidates(const PolygonContainer &polys,
706                                                         const int axis,
707                                                         vector<SortableEntry> &splitCandidates) const;
708
709        /** Selects an axis aligned split plane.
710                Returns true if split is valied
711        */
712        bool SelectAxisAlignedPlane(Plane3 &plane, const PolygonContainer &polys) const;
713
714        /** Bounds ray and returns minT and maxT.
715                @returns true if ray hits BSP tree bounding box
716        */
717        bool BoundRay(const Ray &ray, float &minT, float &maxT) const;
718
719        /** Subdivides the rays into front and back rays according to the split plane.
720               
721                @param plane the split plane
722                @param rays contains the rays to be split. The rays are
723                           distributed into front and back rays.
724                @param frontRays returns rays on the front side of the plane
725                @param backRays returns rays on the back side of the plane
726               
727                @returns the number of splits
728        */
729        int SplitRays(const Plane3 &plane,
730                                  BoundedRayContainer &rays,
731                              BoundedRayContainer &frontRays,
732                                  BoundedRayContainer &backRays);
733
734
735        /** Extracts the split planes representing the space bounded by node n.
736        */
737        void ExtractHalfSpaces(BspNode *n, vector<Plane3> &halfSpaces) const;
738
739        /** Computes the pvs of the front and back leaf with a given classification.
740        */
741        void IncPvs(Intersectable &obj,
742                                  int &frontPvs,
743                                  int &backPvs,
744                                  const int cf,
745                                  const int frontId,
746                                  const int backId,
747                                  const int frontAndBackId) const;
748       
749        int ComputePvsSize(const BoundedRayContainer &rays) const;
750
751        inline bool TerminationCriteriaMet(const BspTraversalData &data) const;
752
753        float AccumulatedRayLength(BoundedRayContainer &rays) const;
754
755        /// Pointer to the root of the tree
756        BspNode *mRoot;
757               
758        BspTreeStatistics mStat;
759
760        /// Strategies for choosing next split plane.
761        enum {NO_STRATEGY = 0,
762                  RANDOM_POLYGON = 1,
763                  AXIS_ALIGNED = 2,
764                  LEAST_SPLITS = 4,
765                  BALANCED_POLYS = 8,
766                  BALANCED_VIEW_CELLS = 16,
767                  LARGEST_POLY_AREA = 32,
768                  VERTICAL_AXIS = 64,
769                  BLOCKED_RAYS = 128,
770                  LEAST_RAY_SPLITS = 256,
771                  BALANCED_RAYS = 512,
772                  PVS = 1024
773                };
774
775        /// box around the whole view domain
776        AxisAlignedBox3 mBox;
777
778        /// view cell corresponding to unbounded space
779        BspViewCell *mRootCell;
780
781        /// should view cells be stored or generated in the leaves?
782        bool mGenerateViewCells;
783
784        /// maximal number of polygons before subdivision termination
785        int mTermMaxPolygons;
786        /// maximal number of rays before subdivision termination
787        int mTermMaxRays;
788        /// maximal possible depth
789        int mTermMaxDepth;
790        /// mininum area
791        float mTermMinArea;
792        /// mininum PVS
793        int mTermMinPvs;
794        /// strategy to get the best split plane
795        int mSplitPlaneStrategy;
796        /// number of candidates evaluated for the next split plane
797        int mMaxPolyCandidates;
798        /// number of candidates for split planes evaluated using the rays
799        int mMaxRayCandidates;
800       
801        /// maximal number of polygons for axis aligned split
802        int mTermMaxPolysForAxisAligned;
803        /// maximal number of rays for axis aligned split
804        int mTermMaxRaysForAxisAligned;
805        /// maximal number of objects for axis aligned split
806        int mTermMaxObjectsForAxisAligned;
807        /// maximal contribution per ray
808        float mTermMaxRayContribution;
809        /// maximal accumulated ray length
810        float mTermMaxAccRayLength;
811
812        float mCtDivCi;
813
814        /// if intersected leaves should be stored with a sample
815        bool mStoreLeavesWithRays;
816
817        /// axis aligned split criteria
818        float mAaCtDivCi;
819        float mSplitBorder;
820        float mMaxCostRatio;
821
822        // factors guiding the split plane heuristics
823        float mVerticalSplitsFactor;
824        float mLargestPolyAreaFactor;
825        float mBlockedRaysFactor;
826        float mLeastRaySplitsFactor;
827        float mBalancedRaysFactor;
828        float mPvsFactor;
829        float mLeastSplitsFactor;
830        float mBalancedPolysFactor;
831        float mBalancedViewCellsFactor;
832
833        //-- thresholds used for view cells merge
834        int mMinPvsDif;
835        int mMinPvs;
836        int mMaxPvs;
837        /// if area or accumulated ray lenght should be used for PVS heuristics
838        bool mPvsUseArea;
839
840private:
841        /** Evaluates split plane classification with respect to the plane's
842                contribution for a balanced tree.
843        */
844        static const float sLeastPolySplitsTable[4];
845        /** Evaluates split plane classification with respect to the plane's
846                contribution for a minimum number splits in the tree.
847        */
848        static const float sBalancedPolysTable[4];
849        /** Evaluates split plane classification with respect to the plane's
850                contribution for a minimum number of ray splits.
851        */
852        static const float sLeastRaySplitsTable[5];
853        /** Evaluates split plane classification with respect to the plane's
854                contribution for balanced rays.
855        */
856        static const float sBalancedRaysTable[5];
857
858};
859
860#endif
Note: See TracBrowser for help on using the repository browser.