Chipmunk  6.0.3
Chipmunk API Reference for Kobold2D developers
cpBody

Data Structures

struct  cpComponentNode
struct  cpBody
 Chipmunk's rigid body struct. More...

Defines

#define cpBodyAssertSane(body)   cpBodySanityCheck(body)
#define CP_DefineBodyStructGetter(type, member, name)   static inline type cpBodyGet##name(const cpBody *body){return body->member;}
#define CP_DefineBodyStructSetter(type, member, name)
#define CP_DefineBodyStructProperty(type, member, name)

Typedefs

typedef void(* cpBodyVelocityFunc )(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)
 Rigid body velocity update function type.
typedef void(* cpBodyPositionFunc )(cpBody *body, cpFloat dt)
 Rigid body position update function type.
typedef void(* cpBodyShapeIteratorFunc )(cpBody *body, cpShape *shape, void *data)
 Body/shape iterator callback function type.
typedef void(* cpBodyConstraintIteratorFunc )(cpBody *body, cpConstraint *constraint, void *data)
 Body/constraint iterator callback function type.
typedef void(* cpBodyArbiterIteratorFunc )(cpBody *body, cpArbiter *arbiter, void *data)
 Body/arbiter iterator callback function type.

Functions

cpBodycpBodyAlloc (void)
 Allocate a cpBody.
cpBodycpBodyInit (cpBody *body, cpFloat m, cpFloat i)
 Initialize a cpBody.
cpBodycpBodyNew (cpFloat m, cpFloat i)
 Allocate and initialize a cpBody.
cpBodycpBodyInitStatic (cpBody *body)
 Initialize a static cpBody.
cpBodycpBodyNewStatic (void)
 Allocate and initialize a static cpBody.
void cpBodyDestroy (cpBody *body)
 Destroy a cpBody.
void cpBodyFree (cpBody *body)
 Destroy and free a cpBody.
void cpBodySanityCheck (cpBody *body)
 Check that the properties of a body is sane. (Only in debug mode)
void cpBodyActivate (cpBody *body)
 Wake up a sleeping or idle body.
void cpBodyActivateStatic (cpBody *body, cpShape *filter)
 Wake up any sleeping or idle bodies touching a static body.
void cpBodySleep (cpBody *body)
 Force a body to fall asleep immediately.
void cpBodySleepWithGroup (cpBody *body, cpBody *group)
 Force a body to fall asleep immediately along with other bodies in a group.
static cpBool cpBodyIsSleeping (const cpBody *body)
 Returns true if the body is sleeping.
static cpBool cpBodyIsStatic (const cpBody *body)
 Returns true if the body is static.
static cpBool cpBodyIsRogue (const cpBody *body)
 Returns true if the body has not been added to a space.
 CP_DefineBodyStructGetter (cpFloat, m, Mass)
void cpBodySetMass (cpBody *body, cpFloat m)
 Set the mass of a body.
 CP_DefineBodyStructGetter (cpFloat, i, Moment)
void cpBodySetMoment (cpBody *body, cpFloat i)
 Set the moment of a body.
 CP_DefineBodyStructGetter (cpVect, p, Pos)
void cpBodySetPos (cpBody *body, cpVect pos)
 Set the position of a body.
 CP_DefineBodyStructProperty (cpVect, v, Vel)
 CP_DefineBodyStructProperty (cpVect, f, Force)
 CP_DefineBodyStructGetter (cpFloat, a, Angle)
void cpBodySetAngle (cpBody *body, cpFloat a)
 Set the angle of a body.
 CP_DefineBodyStructProperty (cpFloat, w, AngVel)
 CP_DefineBodyStructProperty (cpFloat, t, Torque)
 CP_DefineBodyStructGetter (cpVect, rot, Rot)
 CP_DefineBodyStructProperty (cpFloat, v_limit, VelLimit)
 CP_DefineBodyStructProperty (cpFloat, w_limit, AngVelLimit)
 CP_DefineBodyStructProperty (cpDataPointer, data, UserData)
void cpBodyUpdateVelocity (cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)
 Default Integration functions.
void cpBodyUpdatePosition (cpBody *body, cpFloat dt)
static cpVect cpBodyLocal2World (const cpBody *body, const cpVect v)
 Convert body relative/local coordinates to absolute/world coordinates.
static cpVect cpBodyWorld2Local (const cpBody *body, const cpVect v)
 Convert body absolute/world coordinates to relative/local coordinates.
void cpBodyResetForces (cpBody *body)
 Set the forces and torque or a body to zero.
void cpBodyApplyForce (cpBody *body, const cpVect f, const cpVect r)
 Apply an force (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates).
void cpBodyApplyImpulse (cpBody *body, const cpVect j, const cpVect r)
 Apply an impulse (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates).
cpVect cpBodyGetVelAtWorldPoint (cpBody *body, cpVect point)
 Get the velocity on a body (in world units) at a point on the body in world coordinates.
cpVect cpBodyGetVelAtLocalPoint (cpBody *body, cpVect point)
 Get the velocity on a body (in world units) at a point on the body in local coordinates.
static cpFloat cpBodyKineticEnergy (const cpBody *body)
 Get the kinetic energy of a body.
void cpBodyEachShape (cpBody *body, cpBodyShapeIteratorFunc func, void *data)
 Call func once for each shape attached to body and added to the space.
void cpBodyEachConstraint (cpBody *body, cpBodyConstraintIteratorFunc func, void *data)
 Call func once for each constraint attached to body and added to the space.
void cpBodyEachArbiter (cpBody *body, cpBodyArbiterIteratorFunc func, void *data)
 Call func once for each arbiter that is currently active on the body.

Detailed Description

Chipmunk's rigid body type. Rigid bodies hold the physical properties of an object like it's mass, and position and velocity of it's center of gravity. They don't have an shape on their own. They are given a shape by creating collision shapes (cpShape) that point to the body.


Define Documentation

#define CP_DefineBodyStructGetter (   type,
  member,
  name 
)    static inline type cpBodyGet##name(const cpBody *body){return body->member;}
#define CP_DefineBodyStructProperty (   type,
  member,
  name 
)
Value:
CP_DefineBodyStructGetter(type, member, name) \
CP_DefineBodyStructSetter(type, member, name)
#define CP_DefineBodyStructSetter (   type,
  member,
  name 
)
Value:
static inline void cpBodySet##name(cpBody *body, const type value){ \
    cpBodyActivate(body); \
    cpBodyAssertSane(body); \
    body->member = value; \
}
#define cpBodyAssertSane (   body)    cpBodySanityCheck(body)

Typedef Documentation

typedef void(* cpBodyArbiterIteratorFunc)(cpBody *body, cpArbiter *arbiter, void *data)

Body/arbiter iterator callback function type.

typedef void(* cpBodyConstraintIteratorFunc)(cpBody *body, cpConstraint *constraint, void *data)

Body/constraint iterator callback function type.

typedef void(* cpBodyPositionFunc)(cpBody *body, cpFloat dt)

Rigid body position update function type.

typedef void(* cpBodyShapeIteratorFunc)(cpBody *body, cpShape *shape, void *data)

Body/shape iterator callback function type.

typedef void(* cpBodyVelocityFunc)(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)

Rigid body velocity update function type.


Function Documentation

CP_DefineBodyStructGetter ( cpFloat  ,
,
Mass   
)
CP_DefineBodyStructGetter ( cpFloat  ,
,
Moment   
)
CP_DefineBodyStructGetter ( cpVect  ,
,
Pos   
)
CP_DefineBodyStructGetter ( cpFloat  ,
,
Angle   
)
CP_DefineBodyStructGetter ( cpVect  ,
rot  ,
Rot   
)
CP_DefineBodyStructProperty ( cpVect  ,
,
Vel   
)
CP_DefineBodyStructProperty ( cpVect  ,
,
Force   
)
CP_DefineBodyStructProperty ( cpFloat  ,
,
AngVel   
)
CP_DefineBodyStructProperty ( cpFloat  ,
,
Torque   
)
CP_DefineBodyStructProperty ( cpFloat  ,
v_limit  ,
VelLimit   
)
CP_DefineBodyStructProperty ( cpFloat  ,
w_limit  ,
AngVelLimit   
)
CP_DefineBodyStructProperty ( cpDataPointer  ,
data  ,
UserData   
)
void cpBodyActivate ( cpBody body)

Wake up a sleeping or idle body.

void cpBodyActivateStatic ( cpBody body,
cpShape filter 
)

Wake up any sleeping or idle bodies touching a static body.

cpBody* cpBodyAlloc ( void  )

Allocate a cpBody.

void cpBodyApplyForce ( cpBody body,
const cpVect  f,
const cpVect  r 
)

Apply an force (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates).

void cpBodyApplyImpulse ( cpBody body,
const cpVect  j,
const cpVect  r 
)

Apply an impulse (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates).

void cpBodyDestroy ( cpBody body)

Destroy a cpBody.

void cpBodyEachArbiter ( cpBody body,
cpBodyArbiterIteratorFunc  func,
void *  data 
)

Call func once for each arbiter that is currently active on the body.

void cpBodyEachConstraint ( cpBody body,
cpBodyConstraintIteratorFunc  func,
void *  data 
)

Call func once for each constraint attached to body and added to the space.

void cpBodyEachShape ( cpBody body,
cpBodyShapeIteratorFunc  func,
void *  data 
)

Call func once for each shape attached to body and added to the space.

void cpBodyFree ( cpBody body)

Destroy and free a cpBody.

cpVect cpBodyGetVelAtLocalPoint ( cpBody body,
cpVect  point 
)

Get the velocity on a body (in world units) at a point on the body in local coordinates.

cpVect cpBodyGetVelAtWorldPoint ( cpBody body,
cpVect  point 
)

Get the velocity on a body (in world units) at a point on the body in world coordinates.

cpBody* cpBodyInit ( cpBody body,
cpFloat  m,
cpFloat  i 
)

Initialize a cpBody.

cpBody* cpBodyInitStatic ( cpBody body)

Initialize a static cpBody.

static cpBool cpBodyIsRogue ( const cpBody body) [inline, static]

Returns true if the body has not been added to a space.

static cpBool cpBodyIsSleeping ( const cpBody body) [inline, static]

Returns true if the body is sleeping.

static cpBool cpBodyIsStatic ( const cpBody body) [inline, static]

Returns true if the body is static.

static cpFloat cpBodyKineticEnergy ( const cpBody body) [inline, static]

Get the kinetic energy of a body.

static cpVect cpBodyLocal2World ( const cpBody body,
const cpVect  v 
) [inline, static]

Convert body relative/local coordinates to absolute/world coordinates.

cpBody* cpBodyNew ( cpFloat  m,
cpFloat  i 
)

Allocate and initialize a cpBody.

cpBody* cpBodyNewStatic ( void  )

Allocate and initialize a static cpBody.

void cpBodyResetForces ( cpBody body)

Set the forces and torque or a body to zero.

void cpBodySanityCheck ( cpBody body)

Check that the properties of a body is sane. (Only in debug mode)

void cpBodySetAngle ( cpBody body,
cpFloat  a 
)

Set the angle of a body.

void cpBodySetMass ( cpBody body,
cpFloat  m 
)

Set the mass of a body.

void cpBodySetMoment ( cpBody body,
cpFloat  i 
)

Set the moment of a body.

void cpBodySetPos ( cpBody body,
cpVect  pos 
)

Set the position of a body.

void cpBodySleep ( cpBody body)

Force a body to fall asleep immediately.

void cpBodySleepWithGroup ( cpBody body,
cpBody group 
)

Force a body to fall asleep immediately along with other bodies in a group.

void cpBodyUpdatePosition ( cpBody body,
cpFloat  dt 
)
void cpBodyUpdateVelocity ( cpBody body,
cpVect  gravity,
cpFloat  damping,
cpFloat  dt 
)

Default Integration functions.

static cpVect cpBodyWorld2Local ( const cpBody body,
const cpVect  v 
) [inline, static]

Convert body absolute/world coordinates to relative/local coordinates.