dchip.chipmunk

Undocumented in source.

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

QHullPartition
int QHullPartition(cpVect* verts, int count, cpVect a, cpVect b, cpFloat tol)
Undocumented in source. Be warned that the author may not have intended to support it.
QHullReduce
int QHullReduce(cpFloat tol, cpVect* verts, int count, cpVect a, cpVect pivot, cpVect b, cpVect* result)
Undocumented in source. Be warned that the author may not have intended to support it.
SWAP
void SWAP(cpVect a, 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(int numVerts, 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(E condition, string expr, Args args)

Throw a DChipError if condition is false.

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

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

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

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

cpCentroidForPoly
cpVect cpCentroidForPoly(int numVerts, 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
deprecated void cpInitChipmunk()

@deprecated

cpLoopIndexes
void cpLoopIndexes(cpVect* verts, int count, int* start, int* end)
Undocumented in source. Be warned that the author may not have intended to support it.
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, int numVerts, 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(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

CP_VERSION_MINOR
enum CP_VERSION_MINOR;
Undocumented in source.
CP_VERSION_RELEASE
enum CP_VERSION_RELEASE;
Undocumented in source.
cpVersionString
enum cpVersionString;

Version string.

Meta