![]() |
PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
|
BVH: Bounding Volume Hierarchy class. More...
BVH: Bounding Volume Hierarchy class.
The bounding volumes of objects are put in a hierarchical tree. With the help of an octree, we can easily build this hierarchy: First insert the objects into the octree, traverse it from bottom to top: starting with the leaf nodes, we calculate the bounding boxes of the objects in the leaf nodes. Then we go 1 level above, and calculate the bounding volume for the node grouping all its children together. We recursively progressing up towards the root node, where the biggest bounding volume containing all previously calculated bounding volumes is created.
This implementation is basically extending PureOctree nodes with bounding box calculation.
Definition at line 29 of file PureBoundingVolumeHierarchy.h.
#include <PureBoundingVolumeHierarchy.h>
Public Member Functions | |
PureBoundingVolumeHierarchy (const PureVector &pos, TPureFloat size, TPureUInt maxDepthLevel, TPureUInt currentDepthLevel) | |
Creates an octree-derived bounding volume hierarchy (BVH) node. | |
virtual | ~PureBoundingVolumeHierarchy () |
virtual PureBoundingVolumeHierarchy * | insertObject (const PureObject3D &obj) |
Inserts the given object in the octree. | |
virtual const PureBoundingVolumeHierarchy * | findObject (const PureObject3D &obj) const |
Finds the given object in the octree. | |
const PureAxisAlignedBoundingBox & | getAABB () const |
Gets the AABB of this node. | |
![]() | |
PureOctree (const PureVector &pos, TPureFloat size, TPureUInt maxDepthLevel, TPureUInt currentDepthLevel) | |
Creates an octree node. | |
virtual | ~PureOctree () |
ChildIndex | calculateIndex (const PureVector &pos) const |
Calculates child node index for the given position in the current node. | |
TPureUInt | getDepthLevel () const |
Gets the current depth level of the octree node. | |
TPureUInt | getMaxDepthLevel () const |
Gets the maximum depth level of the octree node as it was specified in the constructor of the octree. | |
NodeType | getNodeType () const |
Gets the type of the octree node which depends on if the node has any objects or children nodes. | |
const PureVector & | getPos () const |
Gets the world-space position of the node as specified in the constructor. | |
TPureFloat | getSize () const |
Gets the length of the side of the cube represented by this node as it was specified in the constructor. | |
const std::vector< PureOctree * > & | getChildren () const |
Gets the children nodes of this node. | |
const PureOctree * | getParent () const |
Gets the parent node of this node. | |
const std::set< const PureObject3D * > & | getObjects () const |
Gets the stored objects of this node. | |
Protected Member Functions | |
PureBoundingVolumeHierarchy () | |
PureBoundingVolumeHierarchy (const PureBoundingVolumeHierarchy &) | |
PureBoundingVolumeHierarchy & | operator= (const PureBoundingVolumeHierarchy &) |
virtual TPureBool | subdivide () |
![]() | |
PureOctree () | |
PureOctree (const PureOctree &) | |
PureOctree & | operator= (const PureOctree &) |
void | DeleteChildren () |
Private Attributes | |
PureAxisAlignedBoundingBox | aabb |
Additional Inherited Members | |
![]() | |
enum | NodeType { Parent , LeafEmpty , LeafContainer } |
NodeType tells if the given node has children nodes or Objects. More... | |
typedef TPureUInt | ChildIndex |
ChildIndex indexes a child node within a vector of children nodes. | |
![]() | |
static const ChildIndex | BIT_AXIS_Y = 0 |
Bit to set to TOP or BOTTOM. | |
static const ChildIndex | BIT_AXIS_X = 1 |
Bit to set to LEFT or RIGHT. | |
static const ChildIndex | BIT_AXIS_Z = 2 |
Bit to set to FRONT or BACK. | |
static const ChildIndex | TOP = 0 |
Child is above or in same as parent's position on Y-axis. | |
static const ChildIndex | BOTTOM = BIT(PureOctree::BIT_AXIS_Y) |
Child is under parent's position on Y-axis. | |
static const ChildIndex | LEFT = 0 |
Child is left to parent's position on X-axis. | |
static const ChildIndex | RIGHT = BIT(PureOctree::BIT_AXIS_X) |
Child is right to or in same as parent's position on X-axis. | |
static const ChildIndex | FRONT = 0 |
Child is closer to camera than parent's position on Z-axis. | |
static const ChildIndex | BACK = BIT(PureOctree::BIT_AXIS_Z) |
Child is farther or same distance from camera than parent's position on Z-axis. | |
![]() | |
std::vector< PureOctree * > | vChildren |
PureOctree * | parent |
PureBoundingVolumeHierarchy::PureBoundingVolumeHierarchy | ( | const PureVector & | pos, |
TPureFloat | size, | ||
TPureUInt | maxDepthLevel, | ||
TPureUInt | currentDepthLevel ) |
Creates an octree-derived bounding volume hierarchy (BVH) node.
Basically this is doing the same octree initialization as PureOctree's public constructor.
pos | The world-space position of this node. For global use, you can specify just (0;0;0). |
size | The length of the side of the cube represented by this octree-derived node. Recommend this to be big enough to contain any scene objects. Note that this is NOT the size of the bounding box used by the BVH, that will be calculated. |
maxDepthLevel | The maximum node depth level supported by this BVH. 0 means there is no depth limit. |
currentDepthLevel | The depth level of this specific node being created. For global use, just specify 0 so this will be the root node of the BVH. |
Definition at line 37 of file PureBoundingVolumeHierarchy.cpp.
|
virtual |
Definition at line 44 of file PureBoundingVolumeHierarchy.cpp.
|
protected |
Definition at line 126 of file PureBoundingVolumeHierarchy.cpp.
|
protected |
Definition at line 132 of file PureBoundingVolumeHierarchy.cpp.
|
virtual |
Finds the given object in the octree.
Same behavior as PureOctree::findObject().
obj | The object to be found. |
Reimplemented from PureOctree.
Definition at line 93 of file PureBoundingVolumeHierarchy.cpp.
const PureAxisAlignedBoundingBox & PureBoundingVolumeHierarchy::getAABB | ( | ) | const |
Gets the AABB of this node.
Note that the AABB has nothing to do with the position and size of the ancestor Octree node. Position and size of Octree node is just for determining which node should be the storage for an inserted object. However, the AABB is calculated purely by the position and size of the inserted objects, thus its position and size can easily differ from the position and size of the Octree node.
Definition at line 117 of file PureBoundingVolumeHierarchy.cpp.
|
virtual |
Inserts the given object in the octree.
Same behavior as PureOctree::insertObject().
obj | The object to be inserted in the octree. |
Reimplemented from PureOctree.
Definition at line 57 of file PureBoundingVolumeHierarchy.cpp.
|
protected |
Definition at line 137 of file PureBoundingVolumeHierarchy.cpp.
|
protectedvirtual |
Reimplemented from PureOctree.
Definition at line 143 of file PureBoundingVolumeHierarchy.cpp.
|
private |
Definition at line 61 of file PureBoundingVolumeHierarchy.h.