84 void cpSpaceSetIterations(
cpSpace *space,
int iterations);
100 void cpSpaceSetIdleSpeedThreshold(
cpSpace *space,
cpFloat idleSpeedThreshold);
106 void cpSpaceSetSleepTimeThreshold(
cpSpace *space,
cpFloat sleepTimeThreshold);
113 void cpSpaceSetCollisionSlop(
cpSpace *space,
cpFloat collisionSlop);
119 void cpSpaceSetCollisionBias(
cpSpace *space,
cpFloat collisionBias);
124 void cpSpaceSetCollisionPersistence(
cpSpace *space,
cpTimestamp collisionPersistence);
260 #ifndef CP_SPACE_DISABLE_DEBUG_API 280 typedef enum cpSpaceDebugDrawFlags {
281 CP_SPACE_DEBUG_DRAW_SHAPES = 1<<0,
282 CP_SPACE_DEBUG_DRAW_CONSTRAINTS = 1<<1,
283 CP_SPACE_DEBUG_DRAW_COLLISION_POINTS = 1<<2,
284 } cpSpaceDebugDrawFlags;
Struct that holds function callback pointers to configure custom collision handling.
Definition: cpSpace.h:41
cpDataPointer data
User defined context pointer passed to all of the callback functions as the 'data' argument...
Definition: cpSpace.h:311
int cpSpaceGetIterations(const cpSpace *space)
Number of iterations to use in the impulse solver to solve contacts and other constraints.
void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIteratorFunc func, void *data)
Call func for each body in the space.
cpBool cpSpaceIsLocked(cpSpace *space)
returns true from inside a callback when objects cannot be added/removed.
void cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryFunc func, void *data)
Perform a directed line segment query (like a raycast) against the space calling func for each shape ...
Color type to use with the space debug drawing API.
Definition: cpSpace.h:263
Definition: chipmunk_private.h:641
cpCollisionPreSolveFunc preSolveFunc
This function is called each step when two shapes with types that match this collision handler are co...
Definition: cpSpace.h:52
void(* cpSpaceDebugDrawSegmentImpl)(cpVect a, cpVect b, cpSpaceDebugColor color, cpDataPointer data)
Callback type for a function that draws a line segment.
Definition: cpSpace.h:270
cpSpaceDebugColor shapeOutlineColor
Outline color passed to the drawing function.
Definition: cpSpace.h:302
Fast collision filtering type that is used to determine if two objects collide before calling collisi...
Definition: cpShape.h:52
void * cpDataPointer
Type used for user data pointers.
Definition: chipmunk_types.h:216
cpShape * cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSegmentQueryInfo *out)
Perform a directed line segment query (like a raycast) against the space and return the first shape h...
cpSpaceDebugDrawCircleImpl drawCircle
Function that will be invoked to draw circles.
Definition: cpSpace.h:289
cpSpaceDebugColor constraintColor
Color passed to drawing functions for constraints.
Definition: cpSpace.h:306
cpSpace * cpSpaceAlloc(void)
Allocate a cpSpace.
void(* cpSpaceDebugDrawDotImpl)(cpFloat size, cpVect pos, cpSpaceDebugColor color, cpDataPointer data)
Callback type for a function that draws a dot.
Definition: cpSpace.h:276
void cpSpaceRemoveConstraint(cpSpace *space, cpConstraint *constraint)
Remove a constraint from the simulation.
cpCollisionHandler * cpSpaceAddCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b)
Create or return the existing collision handler for the specified pair of collision types...
cpFloat cpSpaceGetCurrentTimeStep(const cpSpace *space)
Returns the current (or most recent) time step used with the given space.
Definition: chipmunk_private.h:80
Definition: chipmunk_private.h:256
void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count)
Switch the space to use a spatial has as it's spatial index.
cpCollisionPostSolveFunc postSolveFunc
This function is called each step when two shapes with types that match this collision handler are co...
Definition: cpSpace.h:55
unsigned char cpBool
Chipmunk's boolean type.
Definition: chipmunk_types.h:199
void(* cpSpaceShapeIteratorFunc)(cpShape *shape, void *data)
Space/body iterator callback function type.
Definition: cpSpace.h:229
struct cpSpaceDebugColor cpSpaceDebugColor
Color type to use with the space debug drawing API.
cpShape * cpSpaceAddShape(cpSpace *space, cpShape *shape)
Add a collision shape to the simulation.
cpBool(* cpCollisionPreSolveFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData)
Collision pre-solve event function callback type.
Definition: cpSpace.h:33
cpFloat cpSpaceGetCollisionSlop(const cpSpace *space)
Amount of encouraged penetration between colliding shapes.
cpCollisionHandler * cpSpaceAddDefaultCollisionHandler(cpSpace *space)
Create or return the existing collision handler that is called for all collisions that are not handle...
void(* cpSpacePointQueryFunc)(cpShape *shape, cpVect point, cpFloat distance, cpVect gradient, void *data)
Nearest point query callback function type.
Definition: cpSpace.h:196
cpFloat cpSpaceGetIdleSpeedThreshold(const cpSpace *space)
Speed threshold for a body to be considered idle.
cpSpace * cpSpaceInit(cpSpace *space)
Initialize a cpSpace.
void cpSpaceRemoveBody(cpSpace *space, cpBody *body)
Remove a rigid body from the simulation.
void cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data)
Call func for each shape in the space.
cpCollisionBeginFunc beginFunc
This function is called when two shapes with types that match this collision handler begin colliding...
Definition: cpSpace.h:49
uintptr_t cpCollisionType
Type used for cpSpace.collision_type.
Definition: chipmunk_types.h:223
void cpSpaceDebugDraw(cpSpace *space, cpSpaceDebugDrawOptions *options)
Debug draw the current state of the space using the supplied drawing options.
cpBool cpSpaceContainsShape(cpSpace *space, cpShape *shape)
Test if a collision shape has been added to the space.
void cpSpacePointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryFunc func, void *data)
Query the space at a point and call func for each shape found.
unsigned int cpTimestamp
Type used for various timestamps in Chipmunk.
Definition: chipmunk_types.h:244
double cpFloat
Chipmunk's floating point type.
Definition: chipmunk_types.h:83
cpSpaceDebugColor collisionPointColor
Color passed to drawing functions for collision points.
Definition: cpSpace.h:308
const cpCollisionType typeB
Collision type identifier of the second shape that this handler recognizes.
Definition: cpSpace.h:47
void(* cpSpaceShapeQueryFunc)(cpShape *shape, cpContactPointSet *points, void *data)
Shape query callback function type.
Definition: cpSpace.h:216
cpShape * cpSpacePointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpPointQueryInfo *out)
Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found...
cpSpaceDebugDrawDotImpl drawDot
Function that will be invoked to draw dots.
Definition: cpSpace.h:297
cpFloat cpSpaceGetCollisionBias(const cpSpace *space)
Determines how fast overlapping shapes are pushed apart.
cpConstraint * cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint)
Add a constraint to the simulation.
struct cpSpaceDebugDrawOptions cpSpaceDebugDrawOptions
Struct used with cpSpaceDebugDraw() containing drawing callbacks and other drawing settings...
cpBool cpSpaceContainsBody(cpSpace *space, cpBody *body)
Test if a rigid body has been added to the space.
void(* cpSpaceDebugDrawPolygonImpl)(int count, const cpVect *verts, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data)
Callback type for a function that draws a convex polygon.
Definition: cpSpace.h:274
cpBool(* cpCollisionBeginFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData)
Collision begin event function callback type.
Definition: cpSpace.h:30
void cpSpaceStep(cpSpace *space, cpFloat dt)
Step the space forward in time by dt.
cpSpaceDebugDrawFatSegmentImpl drawFatSegment
Function that will be invoked to draw thick line segments.
Definition: cpSpace.h:293
Definition: chipmunk_types.h:271
Segment query info struct.
Definition: cpShape.h:40
void cpSpaceDestroy(cpSpace *space)
Destroy a cpSpace.
cpSpaceDebugDrawColorForShapeImpl colorForShape
Function that decides what fill color to draw shapes using.
Definition: cpSpace.h:304
cpSpaceDebugDrawSegmentImpl drawSegment
Function that will be invoked to draw line segments.
Definition: cpSpace.h:291
void(* cpSpaceBodyIteratorFunc)(cpBody *body, void *data)
Space/body iterator callback function type.
Definition: cpSpace.h:224
cpBool cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data)
Schedule a post-step callback to be called when cpSpaceStep() finishes.
cpSpaceDebugDrawFlags flags
Flags that request which things to draw (collision shapes, constraints, contact points).
Definition: cpSpace.h:300
cpDataPointer cpSpaceGetUserData(const cpSpace *space)
User definable data pointer.
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 cpSpaceFree(cpSpace *space)
Destroy and free a cpSpace.
void(* cpCollisionSeparateFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData)
Collision separate event function callback type.
Definition: cpSpace.h:37
void cpSpaceEachShape(cpSpace *space, cpSpaceShapeIteratorFunc func, void *data)
Call func for each shape in the space.
cpFloat cpSpaceGetDamping(const cpSpace *space)
Damping rate expressed as the fraction of velocity bodies retain each second.
Struct used with cpSpaceDebugDraw() containing drawing callbacks and other drawing settings...
Definition: cpSpace.h:287
void(* cpSpaceDebugDrawCircleImpl)(cpVect pos, cpFloat angle, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data)
Callback type for a function that draws a filled, stroked circle.
Definition: cpSpace.h:268
void(* cpPostStepFunc)(cpSpace *space, void *key, void *data)
Post Step callback function type.
Definition: cpSpace.h:182
Definition: chipmunk_private.h:385
void(* cpCollisionPostSolveFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData)
Collision post-solve event function callback type.
Definition: cpSpace.h:35
cpCollisionHandler * cpSpaceAddWildcardHandler(cpSpace *space, cpCollisionType type)
Create or return the existing wildcard collision handler for the specified type.
void cpSpaceBBQuery(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryFunc func, void *data)
Perform a fast rectangle query on the space calling func for each shape found.
Definition: chipmunk_private.h:185
Point query info struct.
Definition: cpShape.h:27
cpSpace * cpSpaceNew(void)
Allocate and initialize a cpSpace.
cpSpaceDebugDrawPolygonImpl drawPolygon
Function that will be invoked to draw convex polygons.
Definition: cpSpace.h:295
Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)
Definition: cpBB.h:33
void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body)
Update the collision detection data for all shapes attached to a body.
void cpSpaceReindexShape(cpSpace *space, cpShape *shape)
Update the collision detection data for a specific shape in the space.
void cpSpaceRemoveShape(cpSpace *space, cpShape *shape)
Remove a collision shape from the simulation.
cpBody * cpSpaceAddBody(cpSpace *space, cpBody *body)
Add a rigid body to the simulation.
void(* cpSpaceBBQueryFunc)(cpShape *shape, void *data)
Rectangle Query callback function type.
Definition: cpSpace.h:210
cpDataPointer userData
This is a user definable context pointer that is passed to all of the collision handler functions...
Definition: cpSpace.h:59
void cpSpaceReindexStatic(cpSpace *space)
Update the collision detection info for the static shapes in the space.
void(* cpSpaceSegmentQueryFunc)(cpShape *shape, cpVect point, cpVect normal, cpFloat alpha, void *data)
Segment query callback function type.
Definition: cpSpace.h:203
cpTimestamp cpSpaceGetCollisionPersistence(const cpSpace *space)
Number of frames that contact information should persist.
cpFloat cpSpaceGetSleepTimeThreshold(const cpSpace *space)
Time a group of bodies must remain idle in order to fall asleep.
void(* cpSpaceConstraintIteratorFunc)(cpConstraint *constraint, void *data)
Space/constraint iterator callback function type.
Definition: cpSpace.h:234
cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint)
Test if a constraint has been added to the space.
cpBody * cpSpaceGetStaticBody(const cpSpace *space)
The Space provided static body for a given cpSpace.
cpVect cpSpaceGetGravity(const cpSpace *space)
Gravity to pass to rigid bodies when integrating velocity.
cpCollisionSeparateFunc separateFunc
This function is called when two shapes with types that match this collision handler stop colliding...
Definition: cpSpace.h:57
void(* cpSpaceDebugDrawFatSegmentImpl)(cpVect a, cpVect b, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data)
Callback type for a function that draws a thick line segment.
Definition: cpSpace.h:272
cpSpaceDebugColor(* cpSpaceDebugDrawColorForShapeImpl)(cpShape *shape, cpDataPointer data)
Callback type for a function that returns a color for a given shape. This gives you an opportunity to...
Definition: cpSpace.h:278
const cpCollisionType typeA
Collision type identifier of the first shape that this handler recognizes.
Definition: cpSpace.h:44