Chipmunk2D Pro API Reference  6.1.5
 All Classes Functions Variables Typedefs Properties Groups Pages
Classes | Typedefs | Functions
cpShape

The cpShape struct defines the shape of a rigid body. More...

Classes

struct  cpNearestPointQueryInfo
 Nearest point query info struct. More...
 
struct  cpSegmentQueryInfo
 Segment query info struct. More...
 
struct  cpShape
 Opaque collision shape struct. More...
 

Typedefs

typedef struct
cpNearestPointQueryInfo 
cpNearestPointQueryInfo
 Nearest point query info struct.
 
typedef struct cpSegmentQueryInfo cpSegmentQueryInfo
 Segment query info struct.
 

Functions

void cpShapeDestroy (cpShape *shape)
 Destroy a shape.
 
void cpShapeFree (cpShape *shape)
 Destroy and Free a shape.
 
cpBB cpShapeCacheBB (cpShape *shape)
 Update, cache and return the bounding box of a shape based on the body it's attached to.
 
cpBB cpShapeUpdate (cpShape *shape, cpVect pos, cpVect rot)
 Update, cache and return the bounding box of a shape with an explicit transformation.
 
cpBool cpShapePointQuery (cpShape *shape, cpVect p)
 Test if a point lies within a shape.
 
cpFloat cpShapeNearestPointQuery (cpShape *shape, cpVect p, cpNearestPointQueryInfo *out)
 Perform a nearest point query. More...
 
cpBool cpShapeSegmentQuery (cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info)
 Perform a segment query against a shape. info must be a pointer to a valid cpSegmentQueryInfo structure.
 
static cpVect cpSegmentQueryHitPoint (const cpVect start, const cpVect end, const cpSegmentQueryInfo info)
 Get the hit point for a segment query.
 
static cpFloat cpSegmentQueryHitDist (const cpVect start, const cpVect end, const cpSegmentQueryInfo info)
 Get the hit distance for a segment query.
 
void cpResetShapeIdCounter (void)
 When initializing a shape, it's hash value comes from a counter. More...
 

Detailed Description

The cpShape struct defines the shape of a rigid body.

Function Documentation

void cpResetShapeIdCounter ( void  )

When initializing a shape, it's hash value comes from a counter.

Because the hash value may affect iteration order, you can reset the shape ID counter when recreating a space. This will make the simulation be deterministic.

cpFloat cpShapeNearestPointQuery ( cpShape shape,
cpVect  p,
cpNearestPointQueryInfo out 
)

Perform a nearest point query.

It finds the closest point on the surface of shape to a specific point. The value returned is the distance between the points. A negative distance means the point is inside the shape.