Chipmunk2D Pro API Reference  7.0.0
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Classes | Typedefs | Functions | Variables
cpShape

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

Classes

struct  cpPointQueryInfo
 Point query info struct. More...
 
struct  cpSegmentQueryInfo
 Segment query info struct. More...
 
struct  cpShapeFilter
 Fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks. More...
 

Typedefs

typedef struct cpPointQueryInfo cpPointQueryInfo
 Point query info struct.
 
typedef struct cpSegmentQueryInfo cpSegmentQueryInfo
 Segment query info struct.
 
typedef struct cpShapeFilter cpShapeFilter
 Fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks.
 

Functions

static cpShapeFilter cpShapeFilterNew (cpGroup group, cpBitmask categories, cpBitmask mask)
 Create a new collision filter.
 
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, cpTransform transform)
 Update, cache and return the bounding box of a shape with an explicit transformation.
 
cpFloat cpShapePointQuery (const cpShape *shape, cpVect p, cpPointQueryInfo *out)
 Perform a nearest point query. More...
 
cpBool cpShapeSegmentQuery (const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info)
 Perform a segment query against a shape. info must be a pointer to a valid cpSegmentQueryInfo structure.
 
cpContactPointSet cpShapesCollide (const cpShape *a, const cpShape *b)
 Return contact information about two shapes.
 
cpSpacecpShapeGetSpace (const cpShape *shape)
 The cpSpace this body is added to.
 
cpBodycpShapeGetBody (const cpShape *shape)
 The cpBody this shape is connected to.
 
void cpShapeSetBody (cpShape *shape, cpBody *body)
 Set the cpBody this shape is connected to. More...
 
cpFloat cpShapeGetMass (cpShape *shape)
 Get the mass of the shape if you are having Chipmunk calculate mass properties for you.
 
void cpShapeSetMass (cpShape *shape, cpFloat mass)
 Set the mass of this shape to have Chipmunk calculate mass properties for you.
 
cpFloat cpShapeGetDensity (cpShape *shape)
 Get the density of the shape if you are having Chipmunk calculate mass properties for you.
 
void cpShapeSetDensity (cpShape *shape, cpFloat density)
 Set the density of this shape to have Chipmunk calculate mass properties for you.
 
cpFloat cpShapeGetMoment (cpShape *shape)
 Get the calculated moment of inertia for this shape.
 
cpFloat cpShapeGetArea (cpShape *shape)
 Get the calculated area of this shape.
 
cpVect cpShapeGetCenterOfGravity (cpShape *shape)
 Get the centroid of this shape.
 
cpBB cpShapeGetBB (const cpShape *shape)
 Get the bounding box that contains the shape given it's current position and angle.
 
cpBool cpShapeGetSensor (const cpShape *shape)
 Get if the shape is set to be a sensor or not.
 
void cpShapeSetSensor (cpShape *shape, cpBool sensor)
 Set if the shape is a sensor or not.
 
cpFloat cpShapeGetElasticity (const cpShape *shape)
 Get the elasticity of this shape.
 
void cpShapeSetElasticity (cpShape *shape, cpFloat elasticity)
 Set the elasticity of this shape.
 
cpFloat cpShapeGetFriction (const cpShape *shape)
 Get the friction of this shape.
 
void cpShapeSetFriction (cpShape *shape, cpFloat friction)
 Set the friction of this shape.
 
cpVect cpShapeGetSurfaceVelocity (const cpShape *shape)
 Get the surface velocity of this shape.
 
void cpShapeSetSurfaceVelocity (cpShape *shape, cpVect surfaceVelocity)
 Set the surface velocity of this shape.
 
cpDataPointer cpShapeGetUserData (const cpShape *shape)
 Get the user definable data pointer of this shape.
 
void cpShapeSetUserData (cpShape *shape, cpDataPointer userData)
 Set the user definable data pointer of this shape.
 
cpCollisionType cpShapeGetCollisionType (const cpShape *shape)
 Set the collision type of this shape.
 
void cpShapeSetCollisionType (cpShape *shape, cpCollisionType collisionType)
 Get the collision type of this shape.
 
cpShapeFilter cpShapeGetFilter (const cpShape *shape)
 Get the collision filtering parameters of this shape.
 
void cpShapeSetFilter (cpShape *shape, cpShapeFilter filter)
 Set the collision filtering parameters of this shape.
 

Variables

static const cpShapeFilter CP_SHAPE_FILTER_ALL = {CP_NO_GROUP, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES}
 Collision filter value for a shape that will collide with anything except CP_SHAPE_FILTER_NONE.
 
static const cpShapeFilter CP_SHAPE_FILTER_NONE = {CP_NO_GROUP, ~CP_ALL_CATEGORIES, ~CP_ALL_CATEGORIES}
 Collision filter value for a shape that does not collide with anything.
 

Detailed Description

The cpShape struct defines the shape of a rigid body.

Function Documentation

cpFloat cpShapePointQuery ( const cpShape shape,
cpVect  p,
cpPointQueryInfo 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.

void cpShapeSetBody ( cpShape shape,
cpBody body 
)

Set the cpBody this shape is connected to.

Can only be used if the shape is not currently added to a space.