#include <CCollisionAABB.h>
Public Member Functions | |
cCollisionAABB (vector< cTriangle > *a_triangles, bool a_useNeighbors) | |
Constructor of cAABBTree. | |
virtual | ~cCollisionAABB () |
Destructor of cAABBTree. | |
void | initialize (double a_radius=0) |
Build the AABB Tree for the first time. | |
void | render () |
Draw the bounding boxes in OpenGL. | |
bool | computeCollision (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings) |
Return the nearest triangle intersected by the given segment, if any. | |
cCollisionAABBNode * | getRoot () |
Return the root node of the collision tree. | |
Protected Attributes | |
vector< cTriangle > * | m_triangles |
Pointer to the list of triangles in the mesh. | |
cCollisionAABBLeaf * | m_leaves |
Pointer to an array of leaf nodes for the AABB Tree. | |
cCollisionAABBInternal * | m_internalNodes |
Pointer to array of internal nodes. | |
cCollisionAABBNode * | m_root |
Pointer to the root of the AABB Tree. | |
unsigned int | m_numTriangles |
The number of triangles in the mesh. | |
cTriangle * | m_lastCollision |
Triangle returned by last successful collision test. | |
bool | m_useNeighbors |
Use list of triangles' neighbors to speed up collision detection? |
cCollisionAABB::cCollisionAABB | ( | vector< cTriangle > * | a_triangles, | |
bool | a_useNeighbors | |||
) |
Constructor of cAABBTree.
Constructor of cCollisionAABB.
a_triangles | Pointer to array of triangles. | |
a_useNeighbors | Use neighbor lists to speed up collision detection? |
cCollisionAABB::~cCollisionAABB | ( | ) | [virtual] |
Destructor of cAABBTree.
Destructor of cCollisionAABB.
bool cCollisionAABB::computeCollision | ( | cVector3d & | a_segmentPointA, | |
cVector3d & | a_segmentPointB, | |||
cCollisionRecorder & | a_recorder, | |||
cCollisionSettings & | a_settings | |||
) | [virtual] |
Return the nearest triangle intersected by the given segment, if any.
Check if the given line segment intersects any triangle of the mesh. If so, return true, as well as (through the output parameters) pointers to the intersected triangle, the mesh of which this triangle is a part, the point of intersection, and the distance from the origin of the segment to the collision point. If more than one triangle is intersected, return the one closest to the origin of the segment. The method uses the pre-computed AABB boxes, starting at the root and recursing through the tree, breaking the recursion along any path in which the bounding box of the line segment does not intersect the bounding box of the node. At the leafs, triangle-segment intersection testing is called.
a_segmentPointA | Initial point of segment. | |
a_segmentPointB | End point of segment. | |
a_recorder | Stores all collision events | |
a_settings | Contains collision settings information. |
Reimplemented from cGenericCollision.
void cCollisionAABB::initialize | ( | double | a_radius = 0 |
) | [virtual] |
Build the AABB Tree for the first time.
Build the Axis-Aligned Bounding Box collision-detection tree. Each leaf is associated with one triangle and with a bounding box of minimal dimensions such that it fully encloses the triangle and is aligned with the coordinate axes (no rotations). Each internal node is associated with a bounding box of minimal dimensions such that it fully encloses the bounding boxes of its two children and is aligned with the axes.
a_radius | radius to add around the triangles. |
Reimplemented from cGenericCollision.
void cCollisionAABB::render | ( | ) | [virtual] |
Draw the bounding boxes in OpenGL.
Render the bounding boxes of the collision tree in OpenGL.
Reimplemented from cGenericCollision.