#include <CCollisionSpheres.h>
Public Member Functions | |
cCollisionSpheres (vector< cTriangle > *a_triangles, bool a_useNeighbors) | |
Constructor of cCollisionSpheres. | |
virtual | ~cCollisionSpheres () |
Destructor of cCollisionSpheres. | |
void | initialize (double a_radius=0) |
Build the sphere tree based on the given triangles. | |
void | render () |
Draw the collision spheres 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. | |
Public Attributes | |
cCollisionSpheresSphere * | m_root |
Pointer to the sphere at the root of the sphere tree. | |
vector< cTriangle > * | m_trigs |
Pointer to the list of triangles in the mesh. | |
cTriangle * | m_lastCollision |
Triangle returned by last successful collision test. | |
bool | m_useNeighbors |
Use neighbor list to speed up collision detection? | |
cCollisionSpheresLeaf * | m_firstLeaf |
Pointer to the beginning of list of leaf nodes. | |
cTriangle * | secret |
For internal and debug usage. |
cCollisionSpheres::cCollisionSpheres | ( | vector< cTriangle > * | a_triangles, | |
bool | a_useNeighbors | |||
) |
Constructor of cCollisionSpheres.
Constructor of cCollisionSpheres.
a_triangles | Pointer to array of triangles. | |
a_useNeighbors | Use neighbor lists to speed up collision detection? |
bool cCollisionSpheres::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 sphere tree, starting at the root and recursing through the tree, breaking the recursion along any path in which the sphere bounding the line segment does not intersect the sphere 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 cCollisionSpheres::initialize | ( | double | a_radius = 0 |
) | [virtual] |
Build the sphere tree based on the given triangles.
Build the Sphere Tree collision-detection tree. Each leaf is associated with one triangle and with a bounding sphere of minimal radius such that it fully encloses the triangle. Each internal node is associated with a bounding sphere of minimal radius such that it fully encloses the bounding spheres of its two children.
a_radius | radius to add around the triangles. |
Reimplemented from cGenericCollision.
void cCollisionSpheres::render | ( | ) | [virtual] |
Draw the collision spheres in OpenGL.
Draw the collision spheres at the given level.
Reimplemented from cGenericCollision.