dchip.chipmunk

Members

Aliases

cpcalloc
alias cpcalloc = calloc

Chipmunk calloc() alias.

cpfree
alias cpfree = free

Chipmunk free() alias.

cprealloc
alias cprealloc = realloc

Chipmunk realloc() alias.

Classes

DChipError
class DChipError

Throw when an internal library condition is unsatisfied. Continuing the use of the library after this error is thrown will lead to undefined behavior.

Functions

SWAP
void SWAP(ref cpVect a, ref cpVect b)

Avoid bringing in std.algorithm.

cpAreaForCircle
cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2)

Calculate area of a hollow circle. @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.

cpAreaForPoly
cpFloat cpAreaForPoly(const int numVerts, const cpVect* verts)

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.

cpAreaForSegment
cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat r)

Calculate the area of a fattened (capsule shaped) line segment.

cpAssertHard
void cpAssertHard(lazy E condition, lazy string expr, lazy Args args)

Throw a DChipError if condition is false.

cpAssertSoft
void cpAssertSoft(lazy E condition, lazy string expr, lazy Args args)

If the CHIP_ENABLE_WARNINGS version is set, throw a DChipError if condition is false.

cpAssertWarn
void cpAssertWarn(lazy E condition, lazy string expr, lazy Args args)

If the CHIP_ENABLE_WARNINGS version is set, print a warning to stderr if condition is false.

cpCentroidForPoly
cpVect cpCentroidForPoly(const int numVerts, const cpVect* verts)

Calculate the natural centroid of a polygon.

cpConvexHull
int cpConvexHull(int count, cpVect* verts, cpVect* result, int* first, cpFloat tol)

Calculate the convex hull of a given set of points. Returns the count of points in the hull. @c result must be a pointer to a @c cpVect array with at least @c count elements. If @c result is @c NULL, then @c verts will be reduced instead. @c first is an optional pointer to an integer to store where the first vertex in the hull came from (i.e. vertsfirst == result[0]) @c tol is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull. QuickHull seemed like a neat algorithm, and efficient-ish for large input sets. My implementation performs an in place reduction using the result array as scratch space.

cpInitChipmunk
void cpInitChipmunk()

@deprecated

cpMomentForBox
cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height)

Calculate the moment of inertia for a solid box.

cpMomentForBox2
cpFloat cpMomentForBox2(cpFloat m, cpBB box)

Calculate the moment of inertia for a solid box.

cpMomentForCircle
cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset)

Calculate the moment of inertia for a circle. @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.

cpMomentForPoly
cpFloat cpMomentForPoly(cpFloat m, const 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.

cpMomentForSegment
cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b)

Calculate the moment of inertia for a line segment. Beveling radius is not supported.

cpRecenterPoly
void cpRecenterPoly(const int numVerts, cpVect* verts)

Center the polygon on the origin. (Subtracts the centroid of the polygon from each vertex)

Manifest constants

CP_BUFFER_BYTES
enum CP_BUFFER_BYTES;

Allocated size for various Chipmunk buffers.

CP_VERSION_MAJOR
enum CP_VERSION_MAJOR;

Chipmunk 6.2.1

cpVersionString
enum cpVersionString;

Version string.

Meta