Chipmunk2D Pro API Reference  7.0.1
 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.
 
CP_EXPORT void cpShapeDestroy (cpShape *shape)
 Destroy a shape.
 
CP_EXPORT void cpShapeFree (cpShape *shape)
 Destroy and Free a shape.
 
CP_EXPORT cpBB cpShapeCacheBB (cpShape *shape)
 Update, cache and return the bounding box of a shape based on the body it's attached to.
 
CP_EXPORT cpBB cpShapeUpdate (cpShape *shape, cpTransform transform)
 Update, cache and return the bounding box of a shape with an explicit transformation.
 
CP_EXPORT cpFloat cpShapePointQuery (const cpShape *shape, cpVect p, cpPointQueryInfo *out)
 Perform a nearest point query. More...
 
CP_EXPORT 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.
 
CP_EXPORT cpContactPointSet cpShapesCollide (const cpShape *a, const cpShape *b)
 Return contact information about two shapes.
 
CP_EXPORT cpSpacecpShapeGetSpace (const cpShape *shape)
 The cpSpace this body is added to.
 
CP_EXPORT cpBodycpShapeGetBody (const cpShape *shape)
 The cpBody this shape is connected to.
 
CP_EXPORT 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.
 
CP_EXPORT void cpShapeSetMass (cpShape *shape, cpFloat mass)
 Set the mass of this shape to have Chipmunk calculate mass properties for you.
 
CP_EXPORT cpFloat cpShapeGetDensity (cpShape *shape)
 Get the density of the shape if you are having Chipmunk calculate mass properties for you.
 
CP_EXPORT void cpShapeSetDensity (cpShape *shape, cpFloat density)
 Set the density of this shape to have Chipmunk calculate mass properties for you.
 
CP_EXPORT cpFloat cpShapeGetMoment (cpShape *shape)
 Get the calculated moment of inertia for this shape.
 
CP_EXPORT cpFloat cpShapeGetArea (cpShape *shape)
 Get the calculated area of this shape.
 
CP_EXPORT cpVect cpShapeGetCenterOfGravity (cpShape *shape)
 Get the centroid of this shape.
 
CP_EXPORT cpBB cpShapeGetBB (const cpShape *shape)
 Get the bounding box that contains the shape given it's current position and angle.
 
CP_EXPORT cpBool cpShapeGetSensor (const cpShape *shape)
 Get if the shape is set to be a sensor or not.
 
CP_EXPORT void cpShapeSetSensor (cpShape *shape, cpBool sensor)
 Set if the shape is a sensor or not.
 
CP_EXPORT cpFloat cpShapeGetElasticity (const cpShape *shape)
 Get the elasticity of this shape.
 
CP_EXPORT void cpShapeSetElasticity (cpShape *shape, cpFloat elasticity)
 Set the elasticity of this shape.
 
CP_EXPORT cpFloat cpShapeGetFriction (const cpShape *shape)
 Get the friction of this shape.
 
CP_EXPORT void cpShapeSetFriction (cpShape *shape, cpFloat friction)
 Set the friction of this shape.
 
CP_EXPORT cpVect cpShapeGetSurfaceVelocity (const cpShape *shape)
 Get the surface velocity of this shape.
 
CP_EXPORT void cpShapeSetSurfaceVelocity (cpShape *shape, cpVect surfaceVelocity)
 Set the surface velocity of this shape.
 
CP_EXPORT cpDataPointer cpShapeGetUserData (const cpShape *shape)
 Get the user definable data pointer of this shape.
 
CP_EXPORT void cpShapeSetUserData (cpShape *shape, cpDataPointer userData)
 Set the user definable data pointer of this shape.
 
CP_EXPORT cpCollisionType cpShapeGetCollisionType (const cpShape *shape)
 Set the collision type of this shape.
 
CP_EXPORT void cpShapeSetCollisionType (cpShape *shape, cpCollisionType collisionType)
 Get the collision type of this shape.
 
CP_EXPORT cpShapeFilter cpShapeGetFilter (const cpShape *shape)
 Get the collision filtering parameters of this shape.
 
CP_EXPORT 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

CP_EXPORT 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.

CP_EXPORT 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.