#include <CCollisionAABB.h>
Inheritance diagram for cCollisionAABB:
Public Member Functions | |
cCollisionAABB (vector< cTriangle > *a_triangles, bool a_useNeighbors) | |
Constructor of cAABBTree. | |
virtual | ~cCollisionAABB () |
Destructor of cAABBTree. | |
void | initialize () |
Build the AABB Tree for the first time. | |
void | render () |
Draw the bounding boxes in OpenGL. | |
bool | computeCollision (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cGenericObject *&a_colObject, cTriangle *&a_colTriangle, cVector3d &a_colPoint, double &a_colSquareDistance, int a_proxyCall=-1) |
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. | |
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 |
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.
void cCollisionAABB::initialize | ( | ) | [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.
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.
bool cCollisionAABB::computeCollision | ( | cVector3d & | a_segmentPointA, | |
cVector3d & | a_segmentPointB, | |||
cGenericObject *& | a_colObject, | |||
cTriangle *& | a_colTriangle, | |||
cVector3d & | a_colPoint, | |||
double & | a_colSquareDistance, | |||
int | a_proxyCall = -1 | |||
) | [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_colObject | Returns pointer to nearest collided object. | |
a_colTriangle | Returns pointer to nearest collided triangle. | |
a_colPoint | Returns position of nearest collision. | |
a_colSquareDistance | Returns distance between ray origin and collision point. | |
a_proxyCall | If this is > 0, this is a call from a proxy, and the value of a_proxyCall specifies which call this is. When checking for the second and third constraint planes, only the neighbors of the triangle intersected in the first call need be checked, not the whole tree. Call with a_proxyCall = -1 for non-proxy calls. |
Reimplemented from cGenericCollision.
cTriangle* cCollisionAABB::m_lastCollision [protected] |
Triangle returned by last successful collision test.
This is only modified by _proxy_ collision tests.