#include <lib_collider.h>
Collision cache : stores a set of triangles, each with an ID, for use with the other collision classes.
- Note
- Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
The following function fills a GeColliderCache from a BaseObject:
{
return false;
return false;
if (!poly)
return false;
return false;
for (int i = 0; i < poly->GetPolygonCount(); ++i)
{
if (c.
AddTriangle(points[tris[i].a], points[tris[i].b], points[tris[i].c], i) !=
COL_OK)
return false;
}
return false;
return true;
}
◆ GeColliderCache()
◆ ~GeColliderCache()
◆ Alloc()
Allocates a collider cache. Destroy the allocated collider cache with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Returns
- The allocated collider cache, or nullptr if the allocation failed.
◆ Free()
Destructs collider caches allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Parameters
-
[in,out] | data | The collider cache to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards. |
◆ CopyTo()
Copies all triangles to another cache.
- Parameters
-
[in,out] | dest | The destination cache. The caller owns the pointed collider cache. |
- Returns
- true if successful, otherwise false.
◆ BeginInput()
Call this function before storing triangles into the cache. Removes any previous data and allocates space for cnt_tris number of triangles.
- Parameters
-
[in] | cnt_tris | The number of triangles to store. |
- Returns
- The result: COL
◆ AddTriangle()
Adds a triangle to the cache with the specified corners and id.
- Parameters
-
[in] | p1 | The first point. |
[in] | p2 | The second point. |
[in] | p3 | The third point. |
[in] | id | The triangle ID. |
- Returns
- The result: COL
◆ EndInput()
Call this function after storing triangles into the cache.
- Returns
- The result: COL