Classes | Typedefs | Functions

cpSpace

Classes

struct  cpSpace
 Basic Unit of Simulation in Chipmunk. More...

Typedefs

typedef void(* cpPostStepFunc )(cpSpace *space, void *obj, void *data)
 Post Step callback function type.
typedef void(* cpSpacePointQueryFunc )(cpShape *shape, void *data)
 Point query callback function type.
typedef void(* cpSpaceSegmentQueryFunc )(cpShape *shape, cpFloat t, cpVect n, void *data)
 Segment query callback function type.
typedef void(* cpSpaceBBQueryFunc )(cpShape *shape, void *data)
 Rectangle Query callback function type.
typedef void(* cpSpaceShapeQueryFunc )(cpShape *shape, cpContactPointSet *points, void *data)
 Shape query callback function type.
typedef void(* cpSpaceBodyIteratorFunc )(cpBody *body, void *data)
 Space/body iterator callback function type.
typedef void(* cpSpaceShapeIteratorFunc )(cpShape *shape, void *data)
 Space/body iterator callback function type.
typedef void(* cpSpaceConstraintIteratorFunc )(cpConstraint *constraint, void *data)
 Space/constraint iterator callback function type.

Functions

cpSpacecpSpaceAlloc (void)
 Allocate a cpSpace.
cpSpacecpSpaceInit (cpSpace *space)
 Initialize a cpSpace.
cpSpacecpSpaceNew (void)
 Allocate and initialize a cpSpace.
void cpSpaceDestroy (cpSpace *space)
 Destroy a cpSpace.
void cpSpaceFree (cpSpace *space)
 Destroy and free a cpSpace.
static cpBool cpSpaceIsLocked (cpSpace *space)
 returns true from inside a callback and objects cannot be added/removed.
void cpSpaceSetDefaultCollisionHandler (cpSpace *space, cpCollisionBeginFunc begin, cpCollisionPreSolveFunc preSolve, cpCollisionPostSolveFunc postSolve, cpCollisionSeparateFunc separate, void *data)
 Set a default collision handler for this space.
void cpSpaceAddCollisionHandler (cpSpace *space, cpCollisionType a, cpCollisionType b, cpCollisionBeginFunc begin, cpCollisionPreSolveFunc preSolve, cpCollisionPostSolveFunc postSolve, cpCollisionSeparateFunc separate, void *data)
 Set a collision handler to be used whenever the two shapes with the given collision types collide.
void cpSpaceRemoveCollisionHandler (cpSpace *space, cpCollisionType a, cpCollisionType b)
 Unset a collision handler.
cpShapecpSpaceAddShape (cpSpace *space, cpShape *shape)
 Add a collision shape to the simulation.
cpShapecpSpaceAddStaticShape (cpSpace *space, cpShape *shape)
 Explicity add a shape as a static shape to the simulation.
cpBodycpSpaceAddBody (cpSpace *space, cpBody *body)
 Add a rigid body to the simulation.
cpConstraintcpSpaceAddConstraint (cpSpace *space, cpConstraint *constraint)
 Add a constraint to the simulation.
void cpSpaceRemoveShape (cpSpace *space, cpShape *shape)
 Remove a collision shape from the simulation.
void cpSpaceRemoveStaticShape (cpSpace *space, cpShape *shape)
 Remove a collision shape added using cpSpaceAddStaticShape() from the simulation.
void cpSpaceRemoveBody (cpSpace *space, cpBody *body)
 Remove a rigid body from the simulation.
void cpSpaceRemoveConstraint (cpSpace *space, cpConstraint *constraint)
 Remove a constraint from the simulation.
cpBool cpSpaceContainsShape (cpSpace *space, cpShape *shape)
 Test if a collision shape has been added to the space.
cpBool cpSpaceContainsBody (cpSpace *space, cpBody *body)
 Test if a rigid body has been added to the space.
cpBool cpSpaceContainsConstraint (cpSpace *space, cpConstraint *constraint)
 Test if a constraint has been added to the space.
void cpSpaceAddPostStepCallback (cpSpace *space, cpPostStepFunc func, void *obj, void *data)
 Schedule a post-step callback to be called when cpSpaceStep() finishes.
void cpSpacePointQuery (cpSpace *space, cpVect point, cpLayers layers, cpGroup group, cpSpacePointQueryFunc func, void *data)
 Query the space at a point and call func for each shape found.
cpShapecpSpacePointQueryFirst (cpSpace *space, cpVect point, cpLayers layers, cpGroup group)
 Query the space at a point and return the first shape found. Returns NULL if no shapes were found.
void cpSpaceSegmentQuery (cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryFunc func, void *data)
 Perform a directed line segment query (like a raycast) against the space calling func for each shape intersected.
cpShapecpSpaceSegmentQueryFirst (cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSegmentQueryInfo *out)
 Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit.
void cpSpaceBBQuery (cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryFunc func, void *data)
 Perform a fast rectangle query on the space calling func for each shape found.
cpBool cpSpaceShapeQuery (cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data)
 Query a space for any shapes overlapping the given shape and call func for each shape found.
void cpSpaceActivateShapesTouchingShape (cpSpace *space, cpShape *shape)
 Call cpBodyActivate() for any shape that is overlaps the given shape.
void cpSpaceEachBody (cpSpace *space, cpSpaceBodyIteratorFunc func, void *data)
 Call func for each body in the space.
void cpSpaceEachShape (cpSpace *space, cpSpaceShapeIteratorFunc func, void *data)
 Call func for each shape in the space.
void cpSpaceEachConstraint (cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data)
 Call func for each shape in the space.
void cpSpaceReindexStatic (cpSpace *space)
 Update the collision detection info for the static shapes in the space.
void cpSpaceReindexShape (cpSpace *space, cpShape *shape)
 Update the collision detection data for a specific shape in the space.
void cpSpaceReindexShapesForBody (cpSpace *space, cpBody *body)
 Update the collision detection data for all shapes attached to a body.
void cpSpaceUseSpatialHash (cpSpace *space, cpFloat dim, int count)
 Switch the space to use a spatial has as it's spatial index.
void cpSpaceStep (cpSpace *space, cpFloat dt)
 Step the space forward in time by dt.

Function Documentation

void cpSpaceAddCollisionHandler ( cpSpace space,
cpCollisionType  a,
cpCollisionType  b,
cpCollisionBeginFunc  begin,
cpCollisionPreSolveFunc  preSolve,
cpCollisionPostSolveFunc  postSolve,
cpCollisionSeparateFunc  separate,
void *  data 
)

Set a collision handler to be used whenever the two shapes with the given collision types collide.

You can pass NULL for any function you don't want to implement.

void cpSpaceAddPostStepCallback ( cpSpace space,
cpPostStepFunc  func,
void *  obj,
void *  data 
)

Schedule a post-step callback to be called when cpSpaceStep() finishes.

obj is used a key, you can only register one callback per unique value for obj

cpShape* cpSpaceAddShape ( cpSpace space,
cpShape shape 
)

Add a collision shape to the simulation.

If the shape is attached to a static body, it will be added as a static shape.

void cpSpaceBBQuery ( cpSpace space,
cpBB  bb,
cpLayers  layers,
cpGroup  group,
cpSpaceBBQueryFunc  func,
void *  data 
)

Perform a fast rectangle query on the space calling func for each shape found.

Only the shape's bounding boxes are checked for overlap, not their full shape.

void cpSpaceSetDefaultCollisionHandler ( cpSpace space,
cpCollisionBeginFunc  begin,
cpCollisionPreSolveFunc  preSolve,
cpCollisionPostSolveFunc  postSolve,
cpCollisionSeparateFunc  separate,
void *  data 
)

Set a default collision handler for this space.

The default collision handler is invoked for each colliding pair of shapes that isn't explicitly handled by a specific collision handler. You can pass NULL for any function you don't want to implement.

 All Classes Functions Variables Properties