#include <Node.h>
Collaboration diagram for Node:
Public Member Functions | |
Node () | |
Node (const std::vector< Primitive * > primitives) | |
~Node () | |
Node * | left () const |
Node * | right () const |
void | setLeftRight (Node *newleft, Node *newright) |
Axis | splitAxis () const |
void | setSplitAxis (Axis splitaxis) |
float | splitPlane () const |
void | setSplitPlane (float plane) |
void | add (Primitive *primitive) |
Primitive * | primitive (unsigned int index) const |
void | clear_primitives () |
unsigned int | primitives_count () const |
bool | isLeafNode () const |
bool | leafIntersect (Ray &ray, float min, float max) const |
void | nearFar (const Ray &r, Node *&near, Node *&far) const |
float | distanceToSplitPlane (const Ray &ray) const |
Private Attributes | |
Axis | mSplitAxis |
Splitting axis. | |
float | mSplitPlane |
Splitting plane position. | |
Node * | mLeft |
Left child node. | |
Node * | mRight |
Right child node. | |
std::vector< Primitive * > | mPrimitives |
Primitives within this node. |
Definition at line 19 of file Node.h.
Node::Node | ( | const std::vector< Primitive * > | primitives | ) | [inline] |
Node::~Node | ( | ) | [inline] |
Node* Node::left | ( | ) | const [inline] |
Get left child
Definition at line 56 of file Node.h.
References mLeft.
Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), and SAHKDTree::classifyAndSplice().
Node* Node::right | ( | ) | const [inline] |
Get right child
Definition at line 63 of file Node.h.
References mRight.
Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), and SAHKDTree::classifyAndSplice().
Set both children
newleft | New left child, must be not NULL | |
newright | New right child, must be not NULL |
Definition at line 73 of file Node.h.
Referenced by SimpleKDTree::buildTree(), and SAHKDTree::buildTree().
Axis Node::splitAxis | ( | ) | const [inline] |
Get Splitting axis
Definition at line 84 of file Node.h.
References mSplitAxis.
Referenced by SimpleKDTree::buildTree(), and SimpleKDTree::setBestSplit().
void Node::setSplitAxis | ( | Axis | splitaxis | ) | [inline] |
Set splitting axis
Definition at line 91 of file Node.h.
References mSplitAxis.
Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), and SimpleKDTree::setBestSplit().
float Node::splitPlane | ( | ) | const [inline] |
Get splitting plane location
Definition at line 98 of file Node.h.
References mSplitPlane.
Referenced by SimpleKDTree::buildTree().
void Node::setSplitPlane | ( | float | plane | ) | [inline] |
Set splitting plane location
Definition at line 105 of file Node.h.
References mSplitPlane.
Referenced by SAHKDTree::buildTree(), and SimpleKDTree::setBestSplit().
void Node::add | ( | Primitive * | primitive | ) | [inline] |
Add a primitive to list
primitive | New primitive to add |
Definition at line 114 of file Node.h.
References mPrimitives, and primitive().
Referenced by SimpleKDTree::buildTree(), and SAHKDTree::classifyAndSplice().
Primitive* Node::primitive | ( | unsigned int | index | ) | const [inline] |
Get a primitive by index
index | Primitive intex in the list |
Definition at line 124 of file Node.h.
References mPrimitives.
Referenced by add(), SimpleKDTree::buildTree(), SAHKDTree::classifyAndSplice(), and SimpleKDTree::setBestSplit().
void Node::clear_primitives | ( | ) | [inline] |
Clear primitives list
Definition at line 131 of file Node.h.
References mPrimitives.
Referenced by SimpleKDTree::buildTree(), and SAHKDTree::buildTree().
unsigned int Node::primitives_count | ( | ) | const [inline] |
Get number of primitives in the list
Definition at line 140 of file Node.h.
References mPrimitives.
Referenced by SimpleKDTree::buildTree(), SAHKDTree::classifyAndSplice(), SAHKDTree::findBestPlane(), SimpleKDTree::setBestSplit(), SAHKDTree::terminate(), and KDTree::terminate().
bool Node::isLeafNode | ( | ) | const [inline] |
Check whenever the node is a leaf node
Definition at line 147 of file Node.h.
References mSplitAxis, and NO_AXIS.
Referenced by KDTree::intersect().
bool Node::leafIntersect | ( | Ray & | ray, | |
float | min, | |||
float | max | |||
) | const |
Check if ray intersects any object in this node (leaf node). Store the intersection parameters (t and hit) in the ray structure
ray | Ray to intersect with | |
min | Nearest distance to bounding box | |
max | Furthest distance to bounding box |
Definition at line 14 of file Node.cpp.
References EPSILON, mPrimitives, Ray::setHit(), and Ray::t().
Referenced by KDTree::intersect().
Sorts children nodes as near and far. Near child is the one which contains the ray origin
r | Ray to test | |
near | Node that will become the near one | |
far | Node that will become the far one |
Definition at line 169 of file Node.h.
References mLeft, mRight, mSplitAxis, mSplitPlane, and Ray::org().
Referenced by KDTree::intersect().
float Node::distanceToSplitPlane | ( | const Ray & | ray | ) | const [inline] |
Compute distance to the splitting plane
ray | Ray to calculate distance for |
Definition at line 187 of file Node.h.
References Ray::dir(), mSplitAxis, mSplitPlane, and Ray::org().
Referenced by KDTree::intersect().
Axis Node::mSplitAxis [private] |
Splitting axis.
Definition at line 194 of file Node.h.
Referenced by distanceToSplitPlane(), isLeafNode(), nearFar(), setSplitAxis(), and splitAxis().
float Node::mSplitPlane [private] |
Splitting plane position.
Definition at line 197 of file Node.h.
Referenced by distanceToSplitPlane(), nearFar(), setSplitPlane(), and splitPlane().
Node* Node::mLeft [private] |
Node* Node::mRight [private] |
std::vector<Primitive *> Node::mPrimitives [private] |
Primitives within this node.
Definition at line 206 of file Node.h.
Referenced by add(), clear_primitives(), leafIntersect(), primitive(), and primitives_count().