Chipmunk  6.0.3
Chipmunk API Reference for Kobold2D developers
cpShape

Data Structures

struct  cpSegmentQueryInfo
 Segment query info struct. More...
struct  cpShapeClass
struct  cpShape
 Opaque collision shape struct. More...

Defines

#define CP_DefineShapeStructGetter(type, member, name)   static inline type cpShapeGet##name(const cpShape *shape){return shape->member;}
#define CP_DefineShapeStructSetter(type, member, name, activates)
#define CP_DefineShapeStructProperty(type, member, name, activates)
#define CP_DeclareShapeGetter(struct, type, name)   type struct##Get##name(const cpShape *shape)

Typedefs

typedef cpBB(* cpShapeCacheDataImpl )(cpShape *shape, cpVect p, cpVect rot)
typedef void(* cpShapeDestroyImpl )(cpShape *shape)
typedef cpBool(* cpShapePointQueryImpl )(cpShape *shape, cpVect p)
typedef void(* cpShapeSegmentQueryImpl )(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info)

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.
 CP_DefineShapeStructGetter (cpBody *, body, Body)
void cpShapeSetBody (cpShape *shape, cpBody *body)
 CP_DefineShapeStructGetter (cpBB, bb, BB)
 CP_DefineShapeStructProperty (cpBool, sensor, Sensor, cpTrue)
 CP_DefineShapeStructProperty (cpFloat, e, Elasticity, cpFalse)
 CP_DefineShapeStructProperty (cpFloat, u, Friction, cpTrue)
 CP_DefineShapeStructProperty (cpVect, surface_v, SurfaceVelocity, cpTrue)
 CP_DefineShapeStructProperty (cpDataPointer, data, UserData, cpFalse)
 CP_DefineShapeStructProperty (cpCollisionType, collision_type, CollisionType, cpTrue)
 CP_DefineShapeStructProperty (cpGroup, group, Group, cpTrue)
 CP_DefineShapeStructProperty (cpLayers, layers, Layers, cpTrue)
void cpResetShapeIdCounter (void)
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.

Detailed Description

The cpShape struct defines the shape of a rigid body.


Define Documentation

#define CP_DeclareShapeGetter (   struct,
  type,
  name 
)    type struct##Get##name(const cpShape *shape)
#define CP_DefineShapeStructGetter (   type,
  member,
  name 
)    static inline type cpShapeGet##name(const cpShape *shape){return shape->member;}
#define CP_DefineShapeStructProperty (   type,
  member,
  name,
  activates 
)
Value:
CP_DefineShapeStructGetter(type, member, name) \
CP_DefineShapeStructSetter(type, member, name, activates)
#define CP_DefineShapeStructSetter (   type,
  member,
  name,
  activates 
)
Value:
static inline void cpShapeSet##name(cpShape *shape, type value){ \
    if(activates && shape->body) cpBodyActivate(shape->body); \
    shape->member = value; \
}

Typedef Documentation

typedef cpBB(* cpShapeCacheDataImpl)(cpShape *shape, cpVect p, cpVect rot)
typedef void(* cpShapeDestroyImpl)(cpShape *shape)
typedef cpBool(* cpShapePointQueryImpl)(cpShape *shape, cpVect p)
typedef void(* cpShapeSegmentQueryImpl)(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info)

Function Documentation

CP_DefineShapeStructGetter ( cpBody ,
body  ,
Body   
)
CP_DefineShapeStructGetter ( cpBB  ,
bb  ,
BB   
)
CP_DefineShapeStructProperty ( cpBool  ,
sensor  ,
Sensor  ,
cpTrue   
)
CP_DefineShapeStructProperty ( cpFloat  ,
,
Elasticity  ,
cpFalse   
)
CP_DefineShapeStructProperty ( cpFloat  ,
,
Friction  ,
cpTrue   
)
CP_DefineShapeStructProperty ( cpVect  ,
surface_v  ,
SurfaceVelocity  ,
cpTrue   
)
CP_DefineShapeStructProperty ( cpDataPointer  ,
data  ,
UserData  ,
cpFalse   
)
CP_DefineShapeStructProperty ( cpCollisionType  ,
collision_type  ,
CollisionType  ,
cpTrue   
)
CP_DefineShapeStructProperty ( cpGroup  ,
group  ,
Group  ,
cpTrue   
)
CP_DefineShapeStructProperty ( cpLayers  ,
layers  ,
Layers  ,
cpTrue   
)
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.

static cpFloat cpSegmentQueryHitDist ( const cpVect  start,
const cpVect  end,
const cpSegmentQueryInfo  info 
) [inline, static]

Get the hit distance for a segment query.

static cpVect cpSegmentQueryHitPoint ( const cpVect  start,
const cpVect  end,
const cpSegmentQueryInfo  info 
) [inline, static]

Get the hit point for a segment query.

cpBB cpShapeCacheBB ( cpShape shape)

Update, cache and return the bounding box of a shape based on the body it's attached to.

void cpShapeDestroy ( cpShape shape)

Destroy a shape.

void cpShapeFree ( cpShape shape)

Destroy and Free a shape.

cpBool cpShapePointQuery ( cpShape shape,
cpVect  p 
)

Test if a point lies within a shape.

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.

void cpShapeSetBody ( cpShape shape,
cpBody body 
)
cpBB cpShapeUpdate ( cpShape shape,
cpVect  pos,
cpVect  rot 
)

Update, cache and return the bounding box of a shape with an explicit transformation.