Blender V2.61 - r43446
|
Class for a bsp tree for triangles. More...
#include <ntl_bsptree.h>
Public Member Functions | |
ntlTree () | |
Default constructor. | |
ntlTree (int depth, int objnum, ntlScene *scene, int triFlagMask) | |
Constructor with init. | |
~ntlTree () | |
Destructor. | |
void | subdivide (BSPNode *node, int depth, int axis) |
subdivide tree | |
void | intersect (const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const |
intersect ray with BSPtree | |
void | intersectX (const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const |
intersect along +X ray | |
int | getCurrentNodes (void) |
Returns number of nodes. | |
Protected Member Functions | |
bool | checkAABBTriangle (ntlVec3Gfx &min, ntlVec3Gfx &max, ntlTriangle *tri) |
gfxReal | distanceToPlane (BSPNode *curr, ntlVec3Gfx plane, ntlRay ray) const |
distance to plane function for nodes | |
void | getChildren (BSPNode *curr, ntlVec3Gfx origin, BSPNode *&node_near, BSPNode *&node_far) const |
return ordering of children nodes relatice to origin point | |
void | deleteNode (BSPNode *curr) |
delete a node of the tree with all sub nodes, dont delete root members | |
Protected Attributes | |
ntlVec3Gfx | mStart |
AABB for tree. | |
ntlVec3Gfx | mEnd |
int | mMaxDepth |
maximum depth of tree | |
int | mMaxListLength |
maximum number of objects in one node | |
BSPNode * | mpRoot |
root node pointer | |
int | mNumNodes |
count no. of node | |
int | mAbortSubdiv |
BSPStack * | mpNodeStack |
stack for the node pointers | |
vector< ntlVec3Gfx > * | mpVertices |
pointer to vertex array | |
vector< ntlVec3Gfx > * | mpVertNormals |
pointer to vertex array | |
vector< ntlTriangle > * | mpTriangles |
vector for all the triangles | |
vector< ntlTriangle * > * | mppTriangles |
char * | mpTriDist |
temporary array for triangle distribution to nodes | |
TriangleBBox * | mpTBB |
temporary array for triangle bounding boxes | |
int | mTriangleMask |
triangle mask - include only triangles that match mask | |
int | mCurrentDepth |
Status vars (max depth, # of current nodes) | |
int | mCurrentNodes |
int | mTriDoubles |
duplicated triangles, inited during subdivide |
Class for a bsp tree for triangles.
Definition at line 37 of file ntl_bsptree.h.
ntlTree::ntlTree | ( | ) |
Default constructor.
Definition at line 133 of file ntl_bsptree.cpp.
References errFatal, and SIMWORLD_INITERROR.
ntlTree::ntlTree | ( | int | depth, |
int | objnum, | ||
ntlScene * | scene, | ||
int | triFlagMask | ||
) |
Constructor with init.
Definition at line 147 of file ntl_bsptree.cpp.
References BSPNode::axis, AXIS_X, BSP_STACK_SIZE, calcStats(), BSPNode::child, chooseAxis, BSPNode::cloneVec, debMsgStd, debugOutInter, deleteNode(), DM_MSG, doSort, TriangleBBox::end, equal(), errFatal, errMsg, ntlScene::getTrianglePointer(), getVecEpsilon(), ntlScene::getVertexNormalPointer(), ntlScene::getVertexPointer(), globalSortingPoints, i, mAbortSubdiv, BSPNode::max, mCurrentDepth, mCurrentNodes, BSPNode::members, mEnd, BSPNode::min, mMaxDepth, mNumNodes, mpNodeStack, mppTriangles, mpRoot, mpTBB, mpTriangles, mpTriDist, mpVertices, mpVertNormals, mStart, mTriangleMask, mTriDoubles, NULL, SIMWORLD_INITERROR, TriangleBBox::start, subdivide(), and warnMsg.
ntlTree::~ntlTree | ( | ) |
Destructor.
Definition at line 290 of file ntl_bsptree.cpp.
References deleteNode(), mpNodeStack, and mpRoot.
bool ntlTree::checkAABBTriangle | ( | ntlVec3Gfx & | min, |
ntlVec3Gfx & | max, | ||
ntlTriangle * | tri | ||
) | [protected] |
Definition at line 111 of file ntl_bsptree.cpp.
References TriangleBBox::end, ntlTriangle::getBBoxId(), mpTBB, and TriangleBBox::start.
void ntlTree::deleteNode | ( | BSPNode * | curr | ) | [protected] |
delete a node of the tree with all sub nodes, dont delete root members
Definition at line 880 of file ntl_bsptree.cpp.
References BSPNode::child, BSPNode::members, and NULL.
Referenced by ntlTree(), and ~ntlTree().
gfxReal ntlTree::distanceToPlane | ( | BSPNode * | curr, |
ntlVec3Gfx | plane, | ||
ntlRay | ray | ||
) | const [protected] |
distance to plane function for nodes
Definition at line 855 of file ntl_bsptree.cpp.
References BSPNode::axis, ntlRay::getDirection(), and ntlRay::getOrigin().
Referenced by intersect(), and intersectX().
void ntlTree::getChildren | ( | BSPNode * | curr, |
ntlVec3Gfx | origin, | ||
BSPNode *& | node_near, | ||
BSPNode *& | node_far | ||
) | const [protected] |
return ordering of children nodes relatice to origin point
Definition at line 864 of file ntl_bsptree.cpp.
References BSPNode::axis, BSPNode::child, and BSPNode::max.
Referenced by intersect(), and intersectX().
int ntlTree::getCurrentNodes | ( | void | ) | [inline] |
void ntlTree::intersect | ( | const ntlRay & | ray, |
gfxReal & | distance, | ||
ntlVec3Gfx & | normal, | ||
ntlTriangle *& | tri, | ||
int | flags, | ||
bool | forceNonsmooth | ||
) | const |
intersect ray with BSPtree
Definition at line 491 of file ntl_bsptree.cpp.
References BSPNode::axis, BSPNode::child, cross(), distanceToPlane(), BSPStack::elem, getChildren(), ntlRay::getDirection(), ntlRay::getID(), ntlRay::getOrigin(), ntlTriangle::getPoints(), getVecEpsilon(), GFX_REAL_MAX, ntlRay::intersectCompleteAABB(), ntlRay::intersectTriangle(), BSPNode::isLeaf(), BSPNode::max, BSPStackElement::maxdist, BSPNode::members, mEnd, BSPNode::min, BSPStackElement::mindist, mpNodeStack, mpRoot, mpVertices, mpVertNormals, mStart, BSPStackElement::node, normalize(), NULL, and BSPStack::stackPtr.
Referenced by LbmSolverInterface::geoInitCheckPointInside(), and ntlScene::intersectScene().
void ntlTree::intersectX | ( | const ntlRay & | ray, |
gfxReal & | distance, | ||
ntlVec3Gfx & | normal, | ||
ntlTriangle *& | tri, | ||
int | flags, | ||
bool | forceNonsmooth | ||
) | const |
intersect along +X ray
Definition at line 684 of file ntl_bsptree.cpp.
References BSPNode::axis, BSPNode::child, cross(), distanceToPlane(), BSPStack::elem, getChildren(), ntlRay::getDirection(), ntlRay::getID(), ntlRay::getOrigin(), ntlTriangle::getPoints(), getVecEpsilon(), GFX_REAL_MAX, ntlRay::intersectCompleteAABB(), ntlRay::intersectTriangleX(), BSPNode::isLeaf(), BSPNode::max, BSPStackElement::maxdist, BSPNode::members, mEnd, BSPNode::min, BSPStackElement::mindist, mpNodeStack, mpRoot, mpVertices, mpVertNormals, mStart, BSPStackElement::node, normalize(), NULL, and BSPStack::stackPtr.
Referenced by ControlParticles::checkPointInside(), and LbmSolverInterface::geoInitCheckPointInside().
void ntlTree::subdivide | ( | BSPNode * | node, |
int | depth, | ||
int | axis | ||
) |
subdivide tree
Definition at line 301 of file ntl_bsptree.cpp.
References BSPNode::axis, BSPNode::child, chooseAxis, BSPNode::cloneVec, debugOutInter, doSort, TriangleBBox::end, i, mAbortSubdiv, BSPNode::max, mCurrentDepth, mCurrentNodes, BSPNode::members, BSPNode::min, mMaxDepth, mMaxListLength, mNumNodes, mpTBB, mpTriDist, mTriDoubles, NULL, and TriangleBBox::start.
Referenced by ntlTree().
int ntlTree::mAbortSubdiv [protected] |
Definition at line 92 of file ntl_bsptree.h.
Referenced by ntlTree(), and subdivide().
int ntlTree::mCurrentDepth [protected] |
Status vars (max depth, # of current nodes)
Definition at line 118 of file ntl_bsptree.h.
Referenced by ntlTree(), and subdivide().
int ntlTree::mCurrentNodes [protected] |
Definition at line 118 of file ntl_bsptree.h.
Referenced by getCurrentNodes(), ntlTree(), and subdivide().
ntlVec3Gfx ntlTree::mEnd [protected] |
Definition at line 80 of file ntl_bsptree.h.
Referenced by intersect(), intersectX(), and ntlTree().
int ntlTree::mMaxDepth [protected] |
maximum depth of tree
Definition at line 83 of file ntl_bsptree.h.
Referenced by ntlTree(), and subdivide().
int ntlTree::mMaxListLength [protected] |
maximum number of objects in one node
Definition at line 86 of file ntl_bsptree.h.
Referenced by subdivide().
int ntlTree::mNumNodes [protected] |
count no. of node
Definition at line 91 of file ntl_bsptree.h.
Referenced by ntlTree(), and subdivide().
BSPStack* ntlTree::mpNodeStack [protected] |
stack for the node pointers
Definition at line 95 of file ntl_bsptree.h.
Referenced by intersect(), intersectX(), ntlTree(), and ~ntlTree().
vector<ntlTriangle *>* ntlTree::mppTriangles [protected] |
Definition at line 106 of file ntl_bsptree.h.
Referenced by ntlTree().
BSPNode* ntlTree::mpRoot [protected] |
root node pointer
Definition at line 89 of file ntl_bsptree.h.
Referenced by intersect(), intersectX(), ntlTree(), and ~ntlTree().
TriangleBBox* ntlTree::mpTBB [protected] |
temporary array for triangle bounding boxes
Definition at line 112 of file ntl_bsptree.h.
Referenced by checkAABBTriangle(), ntlTree(), and subdivide().
vector<ntlTriangle>* ntlTree::mpTriangles [protected] |
char* ntlTree::mpTriDist [protected] |
temporary array for triangle distribution to nodes
Definition at line 109 of file ntl_bsptree.h.
Referenced by ntlTree(), and subdivide().
vector<ntlVec3Gfx>* ntlTree::mpVertices [protected] |
pointer to vertex array
Definition at line 99 of file ntl_bsptree.h.
Referenced by intersect(), intersectX(), and ntlTree().
vector<ntlVec3Gfx>* ntlTree::mpVertNormals [protected] |
pointer to vertex array
Definition at line 102 of file ntl_bsptree.h.
Referenced by intersect(), intersectX(), and ntlTree().
ntlVec3Gfx ntlTree::mStart [protected] |
AABB for tree.
Definition at line 80 of file ntl_bsptree.h.
Referenced by intersect(), intersectX(), and ntlTree().
int ntlTree::mTriangleMask [protected] |
triangle mask - include only triangles that match mask
Definition at line 115 of file ntl_bsptree.h.
Referenced by ntlTree().
int ntlTree::mTriDoubles [protected] |
duplicated triangles, inited during subdivide
Definition at line 121 of file ntl_bsptree.h.
Referenced by ntlTree(), and subdivide().