#include <lib_collider.h>
Collision engine : contains algorithms for collision detection.
- Note
- Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
if (!o1)
return;
if (!obj1)
return;
FillColliderCache(*o1, *obj1);
return;
if (!obj2)
return;
FillColliderCache(*
o2, *obj2);
return;
for (
int k = 0; k <
e->GetNumPairs(); ++k)
{
}
PyObject * o2
Definition: abstract.h:399
BaseDocument * GetActiveDocument()
void GePrint(const maxon::String &str)
Definition: ge_autoptr.h:37
Definition: c4d_basedocument.h:498
Definition: c4d_baseobject.h:225
Matrix GetMg() const
Definition: c4d_baseobject.h:482
BaseObject * GetNext()
Definition: c4d_baseobject.h:256
static String IntToString(Int32 v)
Definition: c4d_string.h:495
#define COL_ALL_CONTACTS
All contacts.
Definition: lib_collider.h:35
Py_ssize_t * e
Definition: longobject.h:89
const char * doc
Definition: pyerrors.h:226
|
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) |
|
◆ GeColliderEngine()
◆ ~GeColliderEngine()
◆ Alloc()
Allocates a collider engine. Destroy the allocated collider engine with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Returns
- The allocated collider engine, or nullptr if the allocation failed.
◆ Free()
Destructs collider engines allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Parameters
-
[in,out] | data | The collider engine to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards. |
◆ DoCollide()
Checks for intersecting triangles in o1 and o2.
If the function succeeds retrieve a list of colliding triangle pairs with GetNumPairs(), GetId1() and GetId2().
- Note
- The matrices must be orthonormal!
- Parameters
-
[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 |
- Returns
- The result: COL
◆ DoPolyPairs()
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().
- Note
- The matrices must be orthonormal!
- Parameters
-
[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. |
- Returns
- The result: COL
◆ DoTolerance()
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().
- Note
- The matrices must be orthonormal!
- Parameters
-
[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. |
- Returns
- The result: COL
◆ DoDistance()
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().
- Note
- The matrices must be orthonormal!
- Parameters
-
[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. |
- Returns
- The result: COL
◆ FreePairsList()
◆ GetNumPairs()
◆ GetId1()
Retrieves the ID of the first triangle in the pair at k found by DoCollide() or DoPolyPairs().
- Parameters
-
- Returns
- The first triangle ID in pair.
◆ GetId2()
Retrieves the ID of the second triangle in the pair at k found by DoCollide() or DoPolyPairs().
- Parameters
-
- Returns
- The second triangle ID in pair.
◆ IsCloser()
Checks the result of the tolerance check done with DoTolerance().
- Returns
- true if the objects are closer than the tolerance, otherwise false.
◆ GetDistance()
◆ GetP1()
Retrieves the closest point found on the first object during the distance calculation done with DoDistance() or DoTolerance().
- Returns
- The closest point on the first object, in object coordinates.
◆ GetP2()
Retrieves the closest point found on the second object during the distance calculation done with DoDistance() or DoTolerance().
- Returns
- The closest point on the second object, in object coordinates.
◆ DoRayCollide()
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().
- Parameters
-
[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. |
- Returns
- The result: COL