source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.h @ 3280

Revision 3280, 2.0 KB checked in by mattausch, 15 years ago (diff)
RevLine 
[3262]1#ifndef __BVHCONSTRUCTOR_H
2#define __BVHCONSTRUCTOR_H
3
4#include "Bvh.h"
5
6
7
8namespace CHCDemoEngine
9{
10
11/** This class represents a bvh construction algorithm
12*/
13class BvhConstructor
14{
[3264]15public:
16
[3262]17        BvhConstructor(SceneEntity **entities, int first, int last);
18
19        /** Constructs a bvh and returns the root and the number of bvh nodes.
20        */
21        BvhNode *Construct(int &nodes);
22
[3269]23        /** Types of split heuristics.
24        */     
[3280]25        enum {SPATIAL_MEDIAN, OBJECT_MEDIAN, SAH, SAH_OR_SIZE};
[3262]26
27protected:
28
[3269]29        //////////
30        //-- sorting functions
[3262]31
[3269]32        /** The method of subdividing objects into halves in some axis using spatial median
33        */
34        int     SortTrianglesSpatialMedian(BvhLeaf *leaf, int axis);
35        /** The method of subdividing objects into halves in some axis
36                using object median.
37        */
38        int SortTrianglesObjectMedian(BvhLeaf *leaf, int axis, float &pos);
39        /** sort triangles along the axis with respect to the splitting plane
40                given by axis/position return index of the first tiangles belong
41                to the front of the splitting plane.
42        */
43        int     SortTriangles(BvhLeaf *leaf, const int axis, const float position);
44        /** sort triangles by their area.
45        */
46        int SortTrianglesSurfaceArea(BvhLeaf *leaf, float sa);
47        /** This function drives the subdivision.
48        */
[3262]49        BvhNode *SubdivideLeaf(BvhLeaf *leaf, int parentAxis);
50
51        inline bool TerminationCriteriaMet(BvhLeaf *leaf) const;
[3269]52        /** Update the bounding box of this node and the child nodes
53        */
[3267]54        void UpdateBoundingBoxes(BvhNode *node);
[3269]55        /** Select splitting plane using SAH - returns the position of the splitting plane.
56        */
57        float SelectPlaneSah(BvhLeaf *leaf, int &axis, float &minCost);
58        /** evaluate the SAH cost of a particulkar splitting plane
59        */
60        float EvaluateSahCost(BvhLeaf *leaf, int axis, float position);
[3262]61
[3269]62        int CountTriangles(BvhNode *node) const;
[3267]63
[3269]64
65
[3262]66        /////////////////
67
68        SceneEntity **mEntities;
69
70        int mFirst;
71        int mLast;
72
73        int mMaxDepth;
74        int mMaxObjects;
75        int mNumNodes;
[3269]76        int mSplitType;
77        int mMaxTriangles;
[3262]78};
79
80}
81
82#endif // __BVH_H
Note: See TracBrowser for help on using the repository browser.