Generic Octree Class. More...
#include <decOctree.h>
Public Types | |
| enum | eOctants { eoXnegYnegZneg, eoXnegYnegZpos, eoXnegYposZneg, eoXnegYposZpos, eoXposYnegZneg, eoXposYnegZpos, eoXposYposZneg, eoXposYposZpos, eoNotFound, eoFrontLeftTop = eoXnegYposZneg, eoFrontRightTop = eoXposYposZneg, eoFrontLeftBottom = eoXnegYnegZneg, eoFrontRightBottom = eoXposYnegZneg, eoBackLeftTop = eoXnegYposZpos, eoBackRightTop = eoXposYposZpos, eoBackLeftBotom = eoXnegYnegZpos, eoBackRightBottom = eoXposYnegZpos } |
Specified the constants used for the octants. More... | |
Public Member Functions | |
Constructors and Destructors | |
| decOctree (const decVector ¢er, const decVector &halfSize) | |
| Creates a new generic octree object. | |
| virtual | ~decOctree () |
| Cleans up the generic octree object. | |
Management | |
| decOctree * | GetParent () const |
| Retrieves the parent of the octree or NULL if a root octree. | |
| void | SetParent (decOctree *parent) |
| Sets the parent of the octree or NULL if a root octree. | |
| const decVector & | GetCenter () const |
| Retrieves the center of the octree. | |
| const decVector & | GetHalfSize () const |
| Retrieves the half size of the octree. | |
| decOctree * | GetNodeAt (int octant) const |
| Retrieves one of the 8 child nodes. | |
| void | SetNodeAt (int octant, decOctree *octree) |
| Sets one of the eight child nodes. | |
| decOctree * | GetNodeAtBox (const decVector &boxCenter, const decVector &boxHalfSize) |
| Looks for the child node in which the given box lies. | |
| decOctree * | FindNodeAtBox (const decVector &boxCenter, const decVector &boxHalfSize) const |
| Looks for the child node in which the box lies. | |
| int | FindOctantAtBox (const decVector &boxCenter, const decVector &boxHalfSize) const |
| Looks for the octant in which the element lies. | |
| bool | ContainsBox (const decVector &boxCenter, const decVector &boxHalfSize) const |
| Determines if the box is located completely in this node. | |
| decOctree * | FindNodeAtPoint (const decVector &point) const |
| Looks for the child node in which the point lies. | |
| int | FindOctantAtPoint (const decVector &point) const |
| Looks for the octant in which the point lies. | |
| bool | ContainsPoint (const decVector &point) const |
| Determines if the point is located in this node. | |
| decOctree * | SearchTreeForBox (const decVector &boxCenter, const decVector &boxHalfSize) const |
| Searches for the Node containing a given box. | |
| decOctree * | SearchTreeForPoint (const decVector &point) const |
| Searches for the Node where the given point lies in. | |
| void | VisitNodes (decOctreeVisitor *visitor) |
| Visits all nodes. | |
| void | VisitNodesColliding (decOctreeVisitor *visitor, decCollisionVolume *volume) |
| Visits all nodes which collide with the given collision volume. | |
| void | VisitNodesColliding (decOctreeVisitor *visitor, const decVector &boxMinExtend, const decVector &boxMaxExtend) |
| Visits all nodes which collide with the given box. | |
| void | ClearTree (bool clearNodes) |
| Clears the octree. | |
| virtual decOctree * | CreateOctree (int octant) const =0 |
| Creates new octree for the specified octant. | |
| virtual void | ClearNodeContent ()=0 |
| Clears the content of this node. | |
Generic Octree Class.
Provides the generic implementation of an octree algorithm. For real usage subclass this class and implement the required functions. Every Octree object is the root of an octree. The top most octree object with no parent is the real octree root and all children virtual octree roots. The subclass overwrites the node creation function to create nodes of its own class. Furthermore the subclass has to implement the management of the node content. This octree class only provides the skeleton required for an octree algorithm and does not implement any node content logic.
| enum decOctree::eOctants |
Specified the constants used for the octants.
There exists two equal versions suitable for different types of implementations. The first set of octant definitions is classified using the axis coordinates. They are also aligned in a way that the definition value represents a bit mask. The first bit is the x axis, the second the y axis and the third the z axis. A set bit indicates positive direction and a 0 negative direction. This set is useful for implementations working with bit masks to identify octants. The second set of octant definitions uses verbal descriptions of the octants and is useful for implementations based around the logic location of an octant. Both sets include also a definition for a null octant. This is used by functions searching for octants to indicate that no matching octant could be found.
Creates a new generic octree object.
| virtual decOctree::~decOctree | ( | ) | [virtual] |
Cleans up the generic octree object.
| virtual void decOctree::ClearNodeContent | ( | ) | [pure virtual] |
Clears the content of this node.
Implemented in decDefaultOctree.
| void decOctree::ClearTree | ( | bool | clearNodes ) |
Clears the octree.
If clearNodes is set to true all elements are cleared and nodes are reset to NULL. Otherwise only all elements are removed but the nodes stay intact.
Determines if the box is located completely in this node.
| bool decOctree::ContainsPoint | ( | const decVector & | point ) | const |
Determines if the point is located in this node.
| virtual decOctree* decOctree::CreateOctree | ( | int | octant ) | const [pure virtual] |
Creates new octree for the specified octant.
Implement this function to create a new octree of your own type. Do not set the parent of octree. The caller is responsible for this action if applicable.
Implemented in decDefaultOctree.
| decOctree* decOctree::FindNodeAtBox | ( | const decVector & | boxCenter, |
| const decVector & | boxHalfSize | ||
| ) | const |
Looks for the child node in which the box lies.
If found the node is returned. If no node could be found NULL or the node does not exist yet NULL is returned.
Looks for the child node in which the point lies.
If found the node is returned. If no node could be found NULL or the node does not exist yet NULL is returned.
Looks for the octant in which the element lies.
Returns eoNotFound if no octant fully contains the element.
| int decOctree::FindOctantAtPoint | ( | const decVector & | point ) | const |
Looks for the octant in which the point lies.
| const decVector& decOctree::GetCenter | ( | ) | const [inline] |
Retrieves the center of the octree.
| const decVector& decOctree::GetHalfSize | ( | ) | const [inline] |
Retrieves the half size of the octree.
| decOctree* decOctree::GetNodeAt | ( | int | octant ) | const |
Retrieves one of the 8 child nodes.
This is NULL if there exists no such node yet. You can use either an index from 0 to 7 inclusive or use one of the the eOctants constants.
Looks for the child node in which the given box lies.
If the child node does not yet exist it is created. If found the node is returned. If no node could be found NULL is returned.
| decOctree* decOctree::GetParent | ( | ) | const [inline] |
Retrieves the parent of the octree or NULL if a root octree.
| decOctree* decOctree::SearchTreeForBox | ( | const decVector & | boxCenter, |
| const decVector & | boxHalfSize | ||
| ) | const |
Searches for the Node containing a given box.
Searches for the Node where the given point lies in.
| void decOctree::SetNodeAt | ( | int | octant, |
| decOctree * | octree | ||
| ) |
Sets one of the eight child nodes.
You can use either an index from 0 to 7 inclusive or use one of the the eOctant constants. Node can be NULL to remove the child node.
| void decOctree::SetParent | ( | decOctree * | parent ) |
Sets the parent of the octree or NULL if a root octree.
| void decOctree::VisitNodes | ( | decOctreeVisitor * | visitor ) |
Visits all nodes.
| void decOctree::VisitNodesColliding | ( | decOctreeVisitor * | visitor, |
| const decVector & | boxMinExtend, | ||
| const decVector & | boxMaxExtend | ||
| ) |
Visits all nodes which collide with the given box.
| void decOctree::VisitNodesColliding | ( | decOctreeVisitor * | visitor, |
| decCollisionVolume * | volume | ||
| ) |
Visits all nodes which collide with the given collision volume.
1.7.2