Blender V2.61 - r43446

ntl_bsptree.h

Go to the documentation of this file.
00001 
00004 /******************************************************************************
00005  *
00006  * El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
00007  * Copyright 2003-2006 Nils Thuerey
00008  *
00009  * Tree container for fast triangle intersects
00010  *
00011  *****************************************************************************/
00012 #ifndef NTL_TREE_H
00013 #define NTL_TREE_H
00014 
00015 #include "ntl_vector3dim.h"
00016 #include "ntl_ray.h"
00017 
00018 
00019 #define AXIS_X 0
00020 #define AXIS_Y 1
00021 #define AXIS_Z 2
00022 
00023 #define BSP_STACK_SIZE 50
00024 
00025 
00027 //  detailed definition unnecesseary here
00028 class BSPNode;
00029 class BSPStackElement;
00030 class BSPStack;
00031 class TriangleBBox;
00032 class ntlScene;
00033 class ntlTriangle;
00034 
00035 
00037 class ntlTree
00038 {
00039     public:
00040 
00042         ntlTree();
00044         ntlTree(int depth, int objnum, ntlScene *scene, int triFlagMask);
00046         ~ntlTree();
00047 
00049         void subdivide(BSPNode *node, int depth, int axis);
00050 
00052         void intersect(const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const;
00054         void intersectX(const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const;
00055 
00057         int getCurrentNodes( void ) { return mCurrentNodes; }
00058 
00059     protected:
00060 
00061         // check if a triangle is in a node
00062         bool checkAABBTriangle(ntlVec3Gfx &min, ntlVec3Gfx &max, ntlTriangle *tri);
00063 
00064 
00065         // VARs
00066 
00068         gfxReal distanceToPlane(BSPNode *curr, ntlVec3Gfx plane, ntlRay ray) const;
00069 
00071         void getChildren(BSPNode *curr, ntlVec3Gfx origin, BSPNode *&node_near, BSPNode *&node_far) const;
00072 
00074         void deleteNode(BSPNode *curr);
00075 
00076         //inline bool isLeaf(BSPNode *node) const { return (node->child[0] == NULL); }
00077 
00078 
00080         ntlVec3Gfx mStart,mEnd;
00081 
00083         int mMaxDepth;
00084 
00086         int mMaxListLength;
00087 
00089         BSPNode *mpRoot;
00091         int mNumNodes;
00092         int mAbortSubdiv;
00093 
00095         BSPStack *mpNodeStack;
00096         //stack<BSPNode *> nodestack;
00097 
00099         vector<ntlVec3Gfx> *mpVertices;
00100 
00102         vector<ntlVec3Gfx> *mpVertNormals;
00103 
00105         vector<ntlTriangle> *mpTriangles;
00106         vector<ntlTriangle *> *mppTriangles;
00107 
00109         char *mpTriDist;
00110 
00112         TriangleBBox *mpTBB;
00113 
00115         int mTriangleMask;
00116 
00118         int mCurrentDepth, mCurrentNodes;
00119 
00121         int mTriDoubles; 
00122 
00123 };
00124 
00125 
00126 #endif
00127 
00128