Files Class List
BVH Class Referenceabstract

Detailed Description

Bounding Volume Hierarchy class.

#include <cyBVH.h>

Constructor and destructor

 BVH ()
 
virtual ~BVH ()
 
unsigned int GetRootNodeID () const
 
const float * GetNodeBounds (unsigned int nodeID) const
 
bool IsLeafNode (unsigned int nodeID) const
 
unsigned int GetFirstChildNode (unsigned int parentNodeID) const
 
unsigned int GetSecondChildNode (unsigned int parentNodeID) const
 
unsigned int GetSiblingNode (unsigned int firstChildNodeID) const
 
void GetChildNodes (unsigned int parent, unsigned int &child1, unsigned int &child2) const
 
unsigned int GetNodeElementCount (unsigned int nodeID) const
 
const unsigned int * GetNodeElements (unsigned int nodeID) const
 
void Clear ()
 
void Build (unsigned int numElements, unsigned int maxElementsPerNode=CY_BVH_MAX_ELEMENT_COUNT)
 
virtual void GetElementBounds (unsigned int i, float box[6]) const =0
 
virtual float GetElementCenter (unsigned int i, int dimension) const =0
 
virtual unsigned int FindSplit (unsigned int elementCount, unsigned int *elements, const float *box, unsigned int maxElementsPerNode)
 

Constructor & Destructor Documentation

§ BVH()

BVH ( )

the tree structure that keeps all the node data (nodeData[0] is not used for cache coherency)

§ ~BVH()

virtual ~BVH ( )
virtual

the tree structure that keeps all the node data (nodeData[0] is not used for cache coherency)

Member Function Documentation

§ GetRootNodeID()

unsigned int GetRootNodeID ( ) const

Returns the index of the root node.

§ GetNodeBounds()

const float* GetNodeBounds ( unsigned int  nodeID) const

Returns the bounding box of the node as 6 float values. The first 3 values are the minimum x, y, and z coordinates and the last 3 values are the maximum x, y, and z coordinates of the box.

§ IsLeafNode()

bool IsLeafNode ( unsigned int  nodeID) const

Returns true if the node is a leaf node.

§ GetFirstChildNode()

unsigned int GetFirstChildNode ( unsigned int  parentNodeID) const

Returns the index of the first child node (parent must be an internal node).

§ GetSecondChildNode()

unsigned int GetSecondChildNode ( unsigned int  parentNodeID) const

Returns the index of the second child node (parent must be an internal node).

§ GetSiblingNode()

unsigned int GetSiblingNode ( unsigned int  firstChildNodeID) const

Given the first child node index, returns the index of the second child node.

§ GetChildNodes()

void GetChildNodes ( unsigned int  parent,
unsigned int &  child1,
unsigned int &  child2 
) const

Returns the child nodes of the given node (parent must be an internal node).

§ GetNodeElementCount()

unsigned int GetNodeElementCount ( unsigned int  nodeID) const

Returns the number of elements inside the given node (must be a leaf node).

§ GetNodeElements()

const unsigned int* GetNodeElements ( unsigned int  nodeID) const

Returns the list of element inside the given node (must be a leaf node).

§ Clear()

void Clear ( )

Clears the tree structure.

§ Build()

void Build ( unsigned int  numElements,
unsigned int  maxElementsPerNode = CY_BVH_MAX_ELEMENT_COUNT 
)

Builds the tree structure by recursively splitting the nodes. maxElementsPerNode cannot be larger than 8.

§ GetElementBounds()

virtual void GetElementBounds ( unsigned int  i,
float  box[6] 
) const
protectedpure virtual

Sets box as the i^th element's bounding box.

§ GetElementCenter()

virtual float GetElementCenter ( unsigned int  i,
int  dimension 
) const
protectedpure virtual

Returns the center of the i^th element in the given dimension.

§ FindSplit()

virtual unsigned int FindSplit ( unsigned int  elementCount,
unsigned int *  elements,
const float *  box,
unsigned int  maxElementsPerNode 
)
protectedvirtual

Sorts the given elements of a temporary node while building the BVH hierarchy, such that first N elements are to be assigned to the first child and the remaining elements are to be assigned to the second child node, then returns N. Returns zero, if the node is not to be split. The default implementation splits the temporary node down the middle of the widest axis of its bounding box.