#include <KDTree.h>
Inherited by SAHKDTree, and SimpleKDTree.
Inheritance diagram for KDTree:
Public Types | |
typedef std::vector< Primitive * > | PrimitiveList |
Primitive list. | |
Public Member Functions | |
KDTree (unsigned int min_primitives, unsigned int max_depth) | |
virtual | ~KDTree () |
virtual bool | intersect (Ray &ray) const |
virtual void | buildTree (const PrimitiveList &list, const Box &bbox) |
void | setConstraints (unsigned int min_primitives, unsigned int max_depth) |
unsigned int | minPrimitives () const |
unsigned int | maxDepth () const |
Protected Member Functions | |
virtual bool | intersect (const Node *node, Ray &ray, float min, float max) const |
virtual bool | terminate (const Node *current, float dummy, unsigned int depth) const |
Protected Attributes | |
Box | mBoundingBox |
bounding box of the whole tree | |
Node * | mRootNode |
Root node of the tree. | |
unsigned int | mMinPrimitives |
Maximal number of primitives in a leaf node. | |
unsigned int | mMaxDepth |
Tree depth which should be reached. |
Definition at line 21 of file KDTree.h.
typedef std::vector<Primitive *> KDTree::PrimitiveList |
KDTree::KDTree | ( | unsigned int | min_primitives, | |
unsigned int | max_depth | |||
) | [inline] |
KDTree::~KDTree | ( | ) | [virtual] |
bool KDTree::intersect | ( | Ray & | ray | ) | const [virtual] |
Intersect a ray with the kdtree. Store corresponding intersection information if the ray structure (t, hit)
ray | The ray to intersect with, intersection point is stored here |
Definition at line 21 of file KDTree.cpp.
References EPSILON, Box::intersect(), mBoundingBox, and mRootNode.
Referenced by OBJObject::doIntersect(), and intersect().
void KDTree::buildTree | ( | const PrimitiveList & | list, | |
const Box & | bbox | |||
) | [virtual] |
Build the kd-tree from the given primitive list.
list | List of all primitives | |
bbox | Overall bounding box |
Definition at line 97 of file KDTree.cpp.
References LOG, mBoundingBox, and mRootNode.
Referenced by OBJObject::buildAccelStructure(), SimpleKDTree::buildTree(), and SAHKDTree::buildTree().
void KDTree::setConstraints | ( | unsigned int | min_primitives, | |
unsigned int | max_depth | |||
) | [inline] |
Set build tree termination constraints. These numbers declares the minimal possible number of primitives in a leaf node and maximal tree depth
min_primitives | Minimal number of primitives in one node | |
max_depth | Maximal tree depth |
Definition at line 68 of file KDTree.h.
References mMaxDepth, and mMinPrimitives.
unsigned int KDTree::minPrimitives | ( | ) | const [inline] |
unsigned int KDTree::maxDepth | ( | ) | const [inline] |
bool KDTree::intersect | ( | const Node * | node, | |
Ray & | ray, | |||
float | min, | |||
float | max | |||
) | const [protected, virtual] |
Recursive method to look for the intersection
node | Current node | |
ray | The ray to intersect with | |
min | Distance to the near intersection point with the bounding box | |
max | Distance to the far intersection point with the bounding box |
Definition at line 46 of file KDTree.cpp.
References Node::distanceToSplitPlane(), intersect(), Node::isLeafNode(), Node::leafIntersect(), and Node::nearFar().
bool KDTree::terminate | ( | const Node * | current, | |
float | dummy, | |||
unsigned int | depth | |||
) | const [protected, virtual] |
Determine if building tree should terminate on the current node. Default implementation do only subdivide current node if primitive number is still over the minimum and node deep is not too large
current | Current node | |
dummy | Dummy param | |
depth | Depth of the current node |
Reimplemented in SAHKDTree.
Definition at line 122 of file KDTree.cpp.
References mMaxDepth, mMinPrimitives, and Node::primitives_count().
Referenced by SimpleKDTree::buildTree(), and SAHKDTree::terminate().
Box KDTree::mBoundingBox [protected] |
bounding box of the whole tree
Definition at line 91 of file KDTree.h.
Referenced by buildTree(), and intersect().
Node* KDTree::mRootNode [protected] |
Root node of the tree.
Definition at line 94 of file KDTree.h.
Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), buildTree(), intersect(), and ~KDTree().
unsigned int KDTree::mMinPrimitives [protected] |
Maximal number of primitives in a leaf node.
Definition at line 97 of file KDTree.h.
Referenced by minPrimitives(), setConstraints(), and terminate().
unsigned int KDTree::mMaxDepth [protected] |
Tree depth which should be reached.
Definition at line 100 of file KDTree.h.
Referenced by maxDepth(), setConstraints(), and terminate().