#include <lib_collider.h>
Collision engine : contains algorithms for collision detection.
Public Member Functions | |
Int32 | DoCollide (const Matrix &M1, GeColliderCache *o1, const Matrix &M2, GeColliderCache *o2, Int32 flag) |
Int32 | DoPolyPairs (const Matrix &M1, GeColliderCache *o1, const Matrix &M2, GeColliderCache *o2, Float tolerance) |
Int32 | DoTolerance (const Matrix &M1, GeColliderCache *o1, const Matrix &M2, GeColliderCache *o2, Float tolerance) |
Int32 | DoDistance (const Matrix &M1, GeColliderCache *o1, const Matrix &M2, GeColliderCache *o2, Float rel_err, Float abs_err) |
void | FreePairsList () |
Int32 | GetNumPairs () |
Int32 | GetId1 (Int32 k) |
Int32 | GetId2 (Int32 k) |
Bool | IsCloser () |
Float | GetDistance () |
const Vector & | GetP1 () |
const Vector & | GetP2 () |
Int32 | DoRayCollide (GeColliderCache *o1, const Vector &ray_p, const Vector &ray_dir, Float ray_length) |
Static Public Member Functions | |
static GeColliderEngine * | Alloc () |
static void | Free (GeColliderEngine *&data) |
Private Member Functions | |
GeColliderEngine () | |
~GeColliderEngine () | |
|
private |
|
private |
|
static |
|
static |
Int32 DoCollide | ( | const Matrix & | M1, |
GeColliderCache * | o1, | ||
const Matrix & | M2, | ||
GeColliderCache * | o2, | ||
Int32 | flag | ||
) |
Checks for intersecting triangles in o1 and o2.
If the function succeeds retrieve a list of colliding triangle pairs with GetNumPairs(), GetId1() and GetId2().
[in] | M1 | The world matrix of first object. |
[in] | o1 | The cache for first object. |
[in] | M2 | The world matrix of second object. |
[in] | o2 | The cache for second object. |
[in] | flag | The method: COL_CONTACT |
Int32 DoPolyPairs | ( | const Matrix & | M1, |
GeColliderCache * | o1, | ||
const Matrix & | M2, | ||
GeColliderCache * | o2, | ||
Float | tolerance | ||
) |
Checks for triangles in o1 and o2 that are closer than tolerance to each other.
If the function succeeds retrieve a list of colliding triangle pairs with GetNumPairs(), GetId1() and GetId2().
[in] | M1 | The world matrix of first object. |
[in] | o1 | The cache for first object. |
[in] | M2 | The world matrix of second object. |
[in] | o2 | The cache for second object. |
[in] | tolerance | The tolerance. |
Int32 DoTolerance | ( | const Matrix & | M1, |
GeColliderCache * | o1, | ||
const Matrix & | M2, | ||
GeColliderCache * | o2, | ||
Float | tolerance | ||
) |
Checks if o1 and o2 are closer to each other than tolerance.
If the function succeeds check the result with IsCloser(): if it returns true, the proof is in GetDistance(), GetP1() and GetP2().
[in] | M1 | The world matrix of first object. |
[in] | o1 | The cache for first object. |
[in] | M2 | The world matrix of second object. |
[in] | o2 | The cache for second object. |
[in] | tolerance | The tolerance. |
Int32 DoDistance | ( | const Matrix & | M1, |
GeColliderCache * | o1, | ||
const Matrix & | M2, | ||
GeColliderCache * | o2, | ||
Float | rel_err, | ||
Float | abs_err | ||
) |
Calculates the minimum distance between o1 and o2 with the accuracy specified by rel_err and abs_err.
If the function succeeds check the result with GetDistance(). The two closest points can be retrieved with GetP1() and GetP2().
[in] | M1 | The world matrix of first object. |
[in] | o1 | The cache for first object. |
[in] | M2 | The world matrix of second object. |
[in] | o2 | The cache for second object. |
[in] | rel_err | The maximum relative error. |
[in] | abs_err | The maximum absolute error. |
void FreePairsList | ( | ) |
Frees the pairs list.
Int32 GetNumPairs | ( | ) |
Retrieves the number of pairs found by DoCollide() or DoPolyPairs().
Retrieves the ID of the first triangle in the pair at k found by DoCollide() or DoPolyPairs().
[in] | k | The pair index: 0 <= k < GetNumPairs() |
Retrieves the ID of the second triangle in the pair at k found by DoCollide() or DoPolyPairs().
[in] | k | The pair index: 0 <= k < GetNumPairs() |
Bool IsCloser | ( | ) |
Checks the result of the tolerance check done with DoTolerance().
Float GetDistance | ( | ) |
Retrieves the result of the distance calculation done with DoDistance() or DoTolerance().
const Vector& GetP1 | ( | ) |
Retrieves the closest point found on the first object during the distance calculation done with DoDistance() or DoTolerance().
const Vector& GetP2 | ( | ) |
Retrieves the closest point found on the second object during the distance calculation done with DoDistance() or DoTolerance().
Int32 DoRayCollide | ( | GeColliderCache * | o1, |
const Vector & | ray_p, | ||
const Vector & | ray_dir, | ||
Float | ray_length | ||
) |
Checks if the line segment specified by ray_p to ray_p + ray_dir*ray_length intersects the object.
If the function succeeds retrieve the list of intersections with GetNumPairs(), GetId1() and GetId2().
[in] | o1 | The cache for the object. |
[in] | ray_p | The start point of the ray in object coordinates |
[in] | ray_dir | The ray direction in object coordinates. |
[in] | ray_length | The ray length. |