Chipmunk  6.0.3
Chipmunk API Reference for Kobold2D developers
cpSpace

Data Structures

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

Defines

#define CP_DefineSpaceStructGetter(type, member, name)   static inline type cpSpaceGet##name(const cpSpace *space){return space->member;}
#define CP_DefineSpaceStructSetter(type, member, name)   static inline void cpSpaceSet##name(cpSpace *space, type value){space->member = value;}
#define CP_DefineSpaceStructProperty(type, member, name)

Typedefs

typedef struct
cpContactBufferHeader 
cpContactBufferHeader
typedef void(* cpSpaceArbiterApplyImpulseFunc )(cpArbiter *arb)
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.
 CP_DefineSpaceStructProperty (int, iterations, Iterations)
 CP_DefineSpaceStructProperty (cpVect, gravity, Gravity)
 CP_DefineSpaceStructProperty (cpFloat, damping, Damping)
 CP_DefineSpaceStructProperty (cpFloat, idleSpeedThreshold, IdleSpeedThreshold)
 CP_DefineSpaceStructProperty (cpFloat, sleepTimeThreshold, SleepTimeThreshold)
 CP_DefineSpaceStructProperty (cpFloat, collisionSlop, CollisionSlop)
 CP_DefineSpaceStructProperty (cpFloat, collisionBias, CollisionBias)
 CP_DefineSpaceStructProperty (cpTimestamp, collisionPersistence, CollisionPersistence)
 CP_DefineSpaceStructProperty (cpBool, enableContactGraph, EnableContactGraph)
 CP_DefineSpaceStructProperty (cpDataPointer, data, UserData)
 CP_DefineSpaceStructGetter (cpBody *, staticBody, StaticBody)
 CP_DefineSpaceStructGetter (cpFloat, CP_PRIVATE(curr_dt), CurrentTimeStep)
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)
void cpSpaceAddCollisionHandler (cpSpace *space, cpCollisionType a, cpCollisionType b, cpCollisionBeginFunc begin, cpCollisionPreSolveFunc preSolve, cpCollisionPostSolveFunc postSolve, cpCollisionSeparateFunc separate, void *data)
void cpSpaceRemoveCollisionHandler (cpSpace *space, cpCollisionType a, cpCollisionType b)
 Unset a collision handler.
cpShapecpSpaceAddShape (cpSpace *space, cpShape *shape)
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)
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)
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.

Define Documentation

#define CP_DefineSpaceStructGetter (   type,
  member,
  name 
)    static inline type cpSpaceGet##name(const cpSpace *space){return space->member;}
#define CP_DefineSpaceStructProperty (   type,
  member,
  name 
)
Value:
CP_DefineSpaceStructGetter(type, member, name) \
CP_DefineSpaceStructSetter(type, member, name)
#define CP_DefineSpaceStructSetter (   type,
  member,
  name 
)    static inline void cpSpaceSet##name(cpSpace *space, type value){space->member = value;}

Typedef Documentation

typedef void(* cpPostStepFunc)(cpSpace *space, void *obj, void *data)

Post Step callback function type.

typedef void(* cpSpaceBBQueryFunc)(cpShape *shape, void *data)

Rectangle Query callback function type.

typedef void(* cpSpaceBodyIteratorFunc)(cpBody *body, void *data)

Space/body iterator callback function type.

typedef void(* cpSpaceConstraintIteratorFunc)(cpConstraint *constraint, void *data)

Space/constraint iterator 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(* cpSpaceShapeIteratorFunc)(cpShape *shape, void *data)

Space/body iterator callback function type.

typedef void(* cpSpaceShapeQueryFunc)(cpShape *shape, cpContactPointSet *points, void *data)

Shape query callback function type.


Function Documentation

CP_DefineSpaceStructGetter ( cpBody ,
staticBody  ,
StaticBody   
)
CP_DefineSpaceStructGetter ( cpFloat  ,
CP_PRIVATE(curr_dt)  ,
CurrentTimeStep   
)
CP_DefineSpaceStructProperty ( int  ,
iterations  ,
Iterations   
)
CP_DefineSpaceStructProperty ( cpVect  ,
gravity  ,
Gravity   
)
CP_DefineSpaceStructProperty ( cpFloat  ,
damping  ,
Damping   
)
CP_DefineSpaceStructProperty ( cpFloat  ,
idleSpeedThreshold  ,
IdleSpeedThreshold   
)
CP_DefineSpaceStructProperty ( cpFloat  ,
sleepTimeThreshold  ,
SleepTimeThreshold   
)
CP_DefineSpaceStructProperty ( cpFloat  ,
collisionSlop  ,
CollisionSlop   
)
CP_DefineSpaceStructProperty ( cpFloat  ,
collisionBias  ,
CollisionBias   
)
CP_DefineSpaceStructProperty ( cpTimestamp  ,
collisionPersistence  ,
CollisionPersistence   
)
CP_DefineSpaceStructProperty ( cpBool  ,
enableContactGraph  ,
EnableContactGraph   
)
CP_DefineSpaceStructProperty ( cpDataPointer  ,
data  ,
UserData   
)
void cpSpaceActivateShapesTouchingShape ( cpSpace space,
cpShape shape 
)

Call cpBodyActivate() for any shape that is overlaps the given shape.

cpBody* cpSpaceAddBody ( cpSpace space,
cpBody body 
)

Add a rigid body to the simulation.

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.

cpConstraint* cpSpaceAddConstraint ( cpSpace space,
cpConstraint constraint 
)

Add a constraint to the simulation.

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.

cpShape* cpSpaceAddStaticShape ( cpSpace space,
cpShape shape 
)

Explicity add a shape as a static shape to the simulation.

cpSpace* cpSpaceAlloc ( void  )

Allocate a cpSpace.

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.

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.

cpBool cpSpaceContainsShape ( cpSpace space,
cpShape shape 
)

Test if a collision shape has been added to the space.

void cpSpaceDestroy ( cpSpace space)

Destroy a cpSpace.

void cpSpaceEachBody ( cpSpace space,
cpSpaceBodyIteratorFunc  func,
void *  data 
)

Call func for each body in the space.

void cpSpaceEachConstraint ( cpSpace space,
cpSpaceConstraintIteratorFunc  func,
void *  data 
)

Call func for each shape in the space.

void cpSpaceEachShape ( cpSpace space,
cpSpaceShapeIteratorFunc  func,
void *  data 
)

Call func for each shape in the space.

void cpSpaceFree ( cpSpace space)

Destroy and free a cpSpace.

cpSpace* cpSpaceInit ( cpSpace space)

Initialize a cpSpace.

static cpBool cpSpaceIsLocked ( cpSpace space) [inline, static]

returns true from inside a callback and objects cannot be added/removed.

cpSpace* cpSpaceNew ( void  )

Allocate and initialize a cpSpace.

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.

cpShape* cpSpacePointQueryFirst ( 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 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 cpSpaceReindexStatic ( cpSpace space)

Update the collision detection info for the static shapes in the space.

void cpSpaceRemoveBody ( cpSpace space,
cpBody body 
)

Remove a rigid body from the simulation.

void cpSpaceRemoveCollisionHandler ( cpSpace space,
cpCollisionType  a,
cpCollisionType  b 
)

Unset a collision handler.

void cpSpaceRemoveConstraint ( cpSpace space,
cpConstraint constraint 
)

Remove a constraint from 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 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.

cpShape* cpSpaceSegmentQueryFirst ( 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 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.

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 cpSpaceStep ( cpSpace space,
cpFloat  dt 
)

Step the space forward in time by dt.

void cpSpaceUseSpatialHash ( cpSpace space,
cpFloat  dim,
int  count 
)

Switch the space to use a spatial has as it's spatial index.