Cleanup: remove redundant doxygen \file argument
[blender.git] / intern / elbeem / intern / ntl_bsptree.h
1 /** \file \ingroup elbeem
2  */
3 /******************************************************************************
4  *
5  * El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
6  * Copyright 2003-2006 Nils Thuerey
7  *
8  * Tree container for fast triangle intersects
9  *
10  *****************************************************************************/
11 #ifndef NTL_TREE_H
12 #define NTL_TREE_H
13
14 #include "ntl_vector3dim.h"
15 #include "ntl_ray.h"
16
17
18 #define AXIS_X 0
19 #define AXIS_Y 1
20 #define AXIS_Z 2
21
22 #define BSP_STACK_SIZE 50
23
24 #ifdef WITH_CXX_GUARDEDALLOC
25 #  include "MEM_guardedalloc.h"
26 #endif
27
28 //! bsp tree stack classes, defined in ntl_bsptree.cpp,
29 //  detailed definition unnecesseary here
30 class BSPNode;
31 class BSPStackElement;
32 class BSPStack;
33 class TriangleBBox;
34 class ntlScene;
35 class ntlTriangle;
36
37
38 //! Class for a bsp tree for triangles
39 class ntlTree
40 {
41         public:
42
43                 //! Default constructor
44                 ntlTree();
45                 //! Constructor with init
46                 ntlTree(int depth, int objnum, ntlScene *scene, int triFlagMask);
47                 //! Destructor
48                 ~ntlTree();
49
50                 //! subdivide tree
51                 void subdivide(BSPNode *node, int depth, int axis);
52
53                 //! intersect ray with BSPtree
54                 void intersect(const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const;
55                 //! intersect along +X ray
56                 void intersectX(const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const;
57
58                 //! Returns number of nodes
59                 int getCurrentNodes( void ) { return mCurrentNodes; }
60
61         protected:
62
63                 // check if a triangle is in a node
64                 bool checkAABBTriangle(ntlVec3Gfx &min, ntlVec3Gfx &max, ntlTriangle *tri);
65
66
67                 // VARs
68
69                 //! distance to plane function for nodes
70                 gfxReal distanceToPlane(BSPNode *curr, ntlVec3Gfx plane, ntlRay ray) const;
71
72                 //! return ordering of children nodes relatice to origin point
73                 void getChildren(BSPNode *curr, ntlVec3Gfx origin, BSPNode *&node_near, BSPNode *&node_far) const;
74
75                 //! delete a node of the tree with all sub nodes, dont delete root members
76                 void deleteNode(BSPNode *curr);
77
78                 //inline bool isLeaf(BSPNode *node) const { return (node->child[0] == NULL); }
79
80
81                 //! AABB for tree
82                 ntlVec3Gfx mStart,mEnd;
83
84                 //! maximum depth of tree
85                 int mMaxDepth;
86
87                 //! maximum number of objects in one node
88                 int mMaxListLength;
89
90                 //! root node pointer
91                 BSPNode *mpRoot;
92                 //! count no. of node
93                 int mNumNodes;
94                 int mAbortSubdiv;
95
96                 //! stack for the node pointers
97                 BSPStack *mpNodeStack;
98                 //stack<BSPNode *> nodestack;
99
100                 //! pointer to vertex array
101                 vector<ntlVec3Gfx> *mpVertices;
102
103                 //! pointer to vertex array
104                 vector<ntlVec3Gfx> *mpVertNormals;
105
106                 //! vector for all the triangles
107                 vector<ntlTriangle> *mpTriangles;
108                 vector<ntlTriangle *> *mppTriangles;
109
110                 //! temporary array for triangle distribution to nodes
111                 char *mpTriDist;
112
113                 //! temporary array for triangle bounding boxes
114                 TriangleBBox *mpTBB;
115
116                 //! triangle mask - include only triangles that match mask
117                 int mTriangleMask;
118
119                 //! Status vars (max depth, # of current nodes)
120                 int mCurrentDepth, mCurrentNodes;
121
122                 //! duplicated triangles, inited during subdivide 
123                 int mTriDoubles; 
124
125 private:
126 #ifdef WITH_CXX_GUARDEDALLOC
127        MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlTree")
128 #endif
129 };
130
131
132 #endif
133
134