Chipmunk2D Pro API Reference
6.1.5
|
Macros | |
#define | CP_BUFFER_BYTES (32*1024) |
Allocated size for various Chipmunk buffers. | |
#define | cpcalloc calloc |
Chipmunk calloc() alias. | |
#define | cprealloc realloc |
Chipmunk realloc() alias. | |
#define | cpfree free |
Chipmunk free() alias. | |
#define | CP_CONVEX_HULL(__count__, __verts__, __count_var__, __verts_var__) |
Convenience macro to work with cpConvexHull. More... | |
Functions | |
void | cpInitChipmunk (void) |
void | cpEnableSegmentToSegmentCollisions (void) |
Enables segment to segment shape collisions. | |
cpFloat | cpMomentForCircle (cpFloat m, cpFloat r1, cpFloat r2, cpVect offset) |
Calculate the moment of inertia for a circle. More... | |
cpFloat | cpAreaForCircle (cpFloat r1, cpFloat r2) |
Calculate area of a hollow circle. More... | |
cpFloat | cpMomentForSegment (cpFloat m, cpVect a, cpVect b) |
Calculate the moment of inertia for a line segment. More... | |
cpFloat | cpAreaForSegment (cpVect a, cpVect b, cpFloat r) |
Calculate the area of a fattened (capsule shaped) line segment. | |
cpFloat | cpMomentForPoly (cpFloat m, int numVerts, const cpVect *verts, cpVect offset) |
Calculate the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex. | |
cpFloat | cpAreaForPoly (const int numVerts, const cpVect *verts) |
Calculate the signed area of a polygon. More... | |
cpVect | cpCentroidForPoly (const int numVerts, const cpVect *verts) |
Calculate the natural centroid of a polygon. | |
void | cpRecenterPoly (const int numVerts, cpVect *verts) |
Center the polygon on the origin. (Subtracts the centroid of the polygon from each vertex) | |
cpFloat | cpMomentForBox (cpFloat m, cpFloat width, cpFloat height) |
Calculate the moment of inertia for a solid box. | |
cpFloat | cpMomentForBox2 (cpFloat m, cpBB box) |
Calculate the moment of inertia for a solid box. | |
int | cpConvexHull (int count, cpVect *verts, cpVect *result, int *first, cpFloat tol) |
Calculate the convex hull of a given set of points. More... | |
Variables | |
const char * | cpVersionString |
Version string. | |
#define CP_CONVEX_HULL | ( | __count__, | |
__verts__, | |||
__count_var__, | |||
__verts_var__ | |||
) |
Convenience macro to work with cpConvexHull.
count
and verts
is the input array passed to cpConvexHull(). count_var
and verts_var
are the names of the variables the macro creates to store the result. The output vertex array is allocated on the stack using alloca() so it will be freed automatically, but cannot be returned from the current scope.
Calculate area of a hollow circle.
r1
and r2
are the inner and outer diameters. A solid circle has an inner diameter of 0.
Calculate the signed area of a polygon.
A Clockwise winding gives positive area. This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes.
Calculate the convex hull of a given set of points.
Returns the count of points in the hull. result
must be a pointer to a cpVect
array with at least count
elements. If result
is NULL
, then verts
will be reduced instead. first
is an optional pointer to an integer to store where the first vertex in the hull came from (i.e. verts[first] == result[0]) tol
is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull.
void cpInitChipmunk | ( | void | ) |
Calculate the moment of inertia for a circle.
r1
and r2
are the inner and outer diameters. A solid circle has an inner diameter of 0.