Cyclone Cyclone: cyclone::BVHNode< BoundingVolumeClass > Class Template Reference

cyclone::BVHNode< BoundingVolumeClass > Class Template Reference

A base class for nodes in a bounding volume hierarchy. More...

#include <collide_coarse.h>

Collaboration diagram for cyclone::BVHNode< BoundingVolumeClass >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BVHNode (BVHNode *parent, const BoundingVolumeClass &volume, RigidBody *body=NULL)
 Creates a new node in the hierarchy with the given parameters.
bool isLeaf () const
 Checks if this node is at the bottom of the hierarchy.
unsigned getPotentialContacts (PotentialContact *contacts, unsigned limit) const
 >QueryBVH
void insert (RigidBody *body, const BoundingVolumeClass &volume)
 >BVHInsert BVHInsert
 ~BVHNode ()
 >BVHRemove BVHRemove

Public Attributes

BVHNodechildren [2]
 Holds the child nodes of this node.
BoundingVolumeClass volume
 Holds a single bounding volume encompassing all the descendents of this node.
RigidBodybody
 Holds the rigid body at this node of the hierarchy.QueryBVH.
BVHNodeparent
 Holds the node immediately above us in the tree.

Protected Member Functions

bool overlaps (const BVHNode< BoundingVolumeClass > *other) const
 >QueryBVH QueryBVH
unsigned getPotentialContactsWith (const BVHNode< BoundingVolumeClass > *other, PotentialContact *contacts, unsigned limit) const
 QueryBVH.
void recalculateBoundingVolume (bool recurse=true)
 For non-leaf nodes, this method recalculates the bounding volume based on the bounding volumes of its children.

Detailed Description

template<class BoundingVolumeClass>
class cyclone::BVHNode< BoundingVolumeClass >

A base class for nodes in a bounding volume hierarchy.

This class uses a binary tree to store the bounding volumes.


Constructor & Destructor Documentation

template<class BoundingVolumeClass>
cyclone::BVHNode< BoundingVolumeClass >::BVHNode BVHNode< BoundingVolumeClass > *  parent,
const BoundingVolumeClass &  volume,
RigidBody body = NULL
[inline]
 

Creates a new node in the hierarchy with the given parameters.

template<class BoundingVolumeClass>
cyclone::BVHNode< BoundingVolumeClass >::~BVHNode< BoundingVolumeClass >  ) 
 

>BVHRemove BVHRemove

This method deletes the node and all its children (but obviously not the rigid bodies). This also has the effect of deleting the sibling of this node, and changing the parent node so that it contains the data currently in that sibling. Finally it forces the hierarchy above the current node to reconsider its bounding volume.


Member Function Documentation

template<class BoundingVolumeClass>
unsigned cyclone::BVHNode< BoundingVolumeClass >::getPotentialContacts PotentialContact contacts,
unsigned  limit
const
 

>QueryBVH

Returns the number of potential contacts it found.

template<class BoundingVolumeClass>
unsigned cyclone::BVHNode< BoundingVolumeClass >::getPotentialContactsWith const BVHNode< BoundingVolumeClass > *  other,
PotentialContact contacts,
unsigned  limit
const [protected]
 

QueryBVH.

Returns the number of potential contacts it found.

template<class BoundingVolumeClass>
void cyclone::BVHNode< BoundingVolumeClass >::insert RigidBody body,
const BoundingVolumeClass &  volume
 

>BVHInsert BVHInsert

This may involve the creation of further bounding volume nodes.

template<class BoundingVolumeClass>
bool cyclone::BVHNode< BoundingVolumeClass >::isLeaf  )  const [inline]
 

Checks if this node is at the bottom of the hierarchy.

template<class BoundingVolumeClass>
bool cyclone::BVHNode< BoundingVolumeClass >::overlaps const BVHNode< BoundingVolumeClass > *  other  )  const [protected]
 

>QueryBVH QueryBVH

Note that any bounding volume should have an overlaps method implemented that checks for overlapping with another object of its own type.

template<class BoundingVolumeClass>
void cyclone::BVHNode< BoundingVolumeClass >::recalculateBoundingVolume bool  recurse = true  )  [protected]
 

For non-leaf nodes, this method recalculates the bounding volume based on the bounding volumes of its children.


Member Data Documentation

template<class BoundingVolumeClass>
RigidBody* cyclone::BVHNode< BoundingVolumeClass >::body
 

Holds the rigid body at this node of the hierarchy.QueryBVH.

Only leaf nodes can have a rigid body defined (see isLeaf). Note that it is possible to rewrite the algorithms in this class to handle objects at all levels of the hierarchy, but the code provided ignores this vector unless firstChild is NULL.

template<class BoundingVolumeClass>
BVHNode* cyclone::BVHNode< BoundingVolumeClass >::children[2]
 

Holds the child nodes of this node.

template<class BoundingVolumeClass>
BVHNode* cyclone::BVHNode< BoundingVolumeClass >::parent
 

Holds the node immediately above us in the tree.

template<class BoundingVolumeClass>
BoundingVolumeClass cyclone::BVHNode< BoundingVolumeClass >::volume
 

Holds a single bounding volume encompassing all the descendents of this node.


The documentation for this class was generated from the following file: