Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

KDTree Class Template Reference

Class representing a kD-tree acceleration structure for fast ray intersections. More...

#include <kdtree.h>

List of all members.

Public Member Functions

 KDTree ()
 Constructor.
virtual ~KDTree ()
 Destructor.
void buildTree (const std::vector< T * > &objs, int maxDepth=0, int maxObjs=1)
 Builds a tree containing the given objects.
bool intersect (const Ray &ray)
 Returns true if the ray intersects any object stored in the kd-tree.
bool intersect (const Ray &ray, Intersection &is)
 Returns true if the ray intersects any object stored in the kd-tree, and information about the closest intersection point is returned in the supplied Intersection object.

Protected Types

typedef std::vector< int > idxarray
 Integer array used for object indices.

Protected Member Functions

void buildTree (const idxarray &objs, const AABB &bb, int depth, int badRefines)
 Recursive function building the tree.
void classifyObjs (const idxarray &objs, idxarray &objsBelow, idxarray &objsAbove, int axis, int offset)
 Classify an array of objects with respect to the given splitting plane, and put them in the bins for below or above, or in both if they intersect the splitting plane.
float bestSplit (int numObjs, int axis, const AABB &bb, int &offset) const
 Computes the location of the best splitting plane based on the edges of the objects along the given axis.
void setupEdges (const idxarray &objs, int axis)
 Setup the list of bounding box edges for the given objects along the specified axis.
void computeBBox (AABB &world, AABB *boxes) const
 Helper function for computing the bounding boxes of all objects, and a world box enclosing all objects.

Protected Attributes

unsigned int mCurrentRayId
 Current ray mailbox id.
int mNumObjs
 Number of objects stored in the tree.
object * mObjs
 The objects stored in the tree.
int mMaxDepth
 Maximum depth of the node hierarchy.
int mMaxObjs
 Maximum number of objects in a leaf.
std::vector< node > mNodes
 Nodes in the tree.
AABB mWorldBox
 Bounding box enclosing the whole tree.
AABBmBoxes
 Temp array of bounding boxes used during tree construction.
edge * mEdges [3]
 Temp array of edges used during tree construction.
idxarraymObjIdx [2]
 Temp array of object index arrays.
std::vector< nodeTodo > mNodesTodo
 Used during tree traversal.
MemPool< object * > mMemPool
 Memory pool for allocating object* arrays.


Detailed Description

template<class T>
class asr::KDTree< T >

Class representing a kD-tree acceleration structure for fast ray intersections.

The class is templated on the type of the object stored in the tree. The type must be a pointer to a class that has the following functions implemented: ...


The documentation for this class was generated from the following files:
Generated on Sun Mar 26 19:14:12 2006 for ASR by  doxygen 1.4.4