Skip to content

Commit 0593976

Browse files
committed
Added new transform property to cpSpaceDebugDrawOptions
1 parent b43fc1e commit 0593976

File tree

2 files changed

+162
-93
lines changed

2 files changed

+162
-93
lines changed

include/chipmunk/cpSpace.h

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, cpSpace *space, cpDataPo
3838

3939
/// Struct that holds function callback pointers to configure custom collision handling.
4040
/// Collision handlers have a pair of types; when a collision occurs between two shapes that have these types, the collision handler functions are triggered.
41-
struct cpCollisionHandler {
41+
struct cpCollisionHandler
42+
{
4243
/// Collision type identifier of the first shape that this handler recognizes.
4344
/// In the collision handler callback, the shape with this type will be the first argument. Read only.
4445
const cpCollisionType typeA;
@@ -61,22 +62,20 @@ struct cpCollisionHandler {
6162

6263
// TODO: Make timestep a parameter?
6364

64-
6565
//MARK: Memory and Initialization
6666

6767
/// Allocate a cpSpace.
68-
CP_EXPORT cpSpace* cpSpaceAlloc(void);
68+
CP_EXPORT cpSpace *cpSpaceAlloc(void);
6969
/// Initialize a cpSpace.
70-
CP_EXPORT cpSpace* cpSpaceInit(cpSpace *space);
70+
CP_EXPORT cpSpace *cpSpaceInit(cpSpace *space);
7171
/// Allocate and initialize a cpSpace.
72-
CP_EXPORT cpSpace* cpSpaceNew(void);
72+
CP_EXPORT cpSpace *cpSpaceNew(void);
7373

7474
/// Destroy a cpSpace.
7575
CP_EXPORT void cpSpaceDestroy(cpSpace *space);
7676
/// Destroy and free a cpSpace.
7777
CP_EXPORT void cpSpaceFree(cpSpace *space);
7878

79-
8079
//MARK: Properties
8180

8281
/// Number of iterations to use in the impulse solver to solve contacts and other constraints.
@@ -131,7 +130,7 @@ CP_EXPORT void cpSpaceSetUserData(cpSpace *space, cpDataPointer userData);
131130

132131
/// The Space provided static body for a given cpSpace.
133132
/// This is merely provided for convenience and you are not required to use it.
134-
CP_EXPORT cpBody* cpSpaceGetStaticBody(const cpSpace *space);
133+
CP_EXPORT cpBody *cpSpaceGetStaticBody(const cpSpace *space);
135134

136135
/// Returns the current (or most recent) time step used with the given space.
137136
/// Useful from callbacks if your time step is not a compile-time global.
@@ -140,7 +139,6 @@ CP_EXPORT cpFloat cpSpaceGetCurrentTimeStep(const cpSpace *space);
140139
/// returns true from inside a callback when objects cannot be added/removed.
141140
CP_EXPORT cpBool cpSpaceIsLocked(cpSpace *space);
142141

143-
144142
//MARK: Collision Handlers
145143

146144
/// Create or return the existing collision handler that is called for all collisions that are not handled by a more specific collision handler.
@@ -151,16 +149,15 @@ CP_EXPORT cpCollisionHandler *cpSpaceAddCollisionHandler(cpSpace *space, cpColli
151149
/// Create or return the existing wildcard collision handler for the specified type.
152150
CP_EXPORT cpCollisionHandler *cpSpaceAddWildcardHandler(cpSpace *space, cpCollisionType type);
153151

154-
155152
//MARK: Add/Remove objects
156153

157154
/// Add a collision shape to the simulation.
158155
/// If the shape is attached to a static body, it will be added as a static shape.
159-
CP_EXPORT cpShape* cpSpaceAddShape(cpSpace *space, cpShape *shape);
156+
CP_EXPORT cpShape *cpSpaceAddShape(cpSpace *space, cpShape *shape);
160157
/// Add a rigid body to the simulation.
161-
CP_EXPORT cpBody* cpSpaceAddBody(cpSpace *space, cpBody *body);
158+
CP_EXPORT cpBody *cpSpaceAddBody(cpSpace *space, cpBody *body);
162159
/// Add a constraint to the simulation.
163-
CP_EXPORT cpConstraint* cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint);
160+
CP_EXPORT cpConstraint *cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint);
164161

165162
/// Remove a collision shape from the simulation.
166163
CP_EXPORT void cpSpaceRemoveShape(cpSpace *space, cpShape *shape);
@@ -186,7 +183,6 @@ typedef void (*cpPostStepFunc)(cpSpace *space, void *key, void *data);
186183
/// It's possible to pass @c NULL for @c func if you only want to mark @c key as being used.
187184
CP_EXPORT cpBool cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data);
188185

189-
190186
//MARK: Queries
191187

192188
// TODO: Queries and iterators should take a cpSpace parametery.
@@ -217,7 +213,6 @@ typedef void (*cpSpaceShapeQueryFunc)(cpShape *shape, cpContactPointSet *points,
217213
/// Query a space for any shapes overlapping the given shape and call @c func for each shape found.
218214
CP_EXPORT cpBool cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data);
219215

220-
221216
//MARK: Iteration
222217

223218
/// Space/body iterator callback function type.
@@ -235,7 +230,6 @@ typedef void (*cpSpaceConstraintIteratorFunc)(cpConstraint *constraint, void *da
235230
/// Call @c func for each shape in the space.
236231
CP_EXPORT void cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data);
237232

238-
239233
//MARK: Indexing
240234

241235
/// Update the collision detection info for the static shapes in the space.
@@ -248,19 +242,18 @@ CP_EXPORT void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body);
248242
/// Switch the space to use a spatial has as it's spatial index.
249243
CP_EXPORT void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count);
250244

251-
252245
//MARK: Time Stepping
253246

254247
/// Step the space forward in time by @c dt.
255248
CP_EXPORT void cpSpaceStep(cpSpace *space, cpFloat dt);
256249

257-
258250
//MARK: Debug API
259251

260252
#ifndef CP_SPACE_DISABLE_DEBUG_API
261253

262254
/// Color type to use with the space debug drawing API.
263-
typedef struct cpSpaceDebugColor {
255+
typedef struct cpSpaceDebugColor
256+
{
264257
float r, g, b, a;
265258
} cpSpaceDebugColor;
266259

@@ -277,14 +270,16 @@ typedef void (*cpSpaceDebugDrawDotImpl)(cpFloat size, cpVect pos, cpSpaceDebugCo
277270
/// Callback type for a function that returns a color for a given shape. This gives you an opportunity to color shapes based on how they are used in your engine.
278271
typedef cpSpaceDebugColor (*cpSpaceDebugDrawColorForShapeImpl)(cpShape *shape, cpDataPointer data);
279272

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,
273+
typedef enum cpSpaceDebugDrawFlags
274+
{
275+
CP_SPACE_DEBUG_DRAW_SHAPES = 1 << 0,
276+
CP_SPACE_DEBUG_DRAW_CONSTRAINTS = 1 << 1,
277+
CP_SPACE_DEBUG_DRAW_COLLISION_POINTS = 1 << 2,
284278
} cpSpaceDebugDrawFlags;
285279

286280
/// Struct used with cpSpaceDebugDraw() containing drawing callbacks and other drawing settings.
287-
typedef struct cpSpaceDebugDrawOptions {
281+
typedef struct cpSpaceDebugDrawOptions
282+
{
288283
/// Function that will be invoked to draw circles.
289284
cpSpaceDebugDrawCircleImpl drawCircle;
290285
/// Function that will be invoked to draw line segments.
@@ -295,7 +290,7 @@ typedef struct cpSpaceDebugDrawOptions {
295290
cpSpaceDebugDrawPolygonImpl drawPolygon;
296291
/// Function that will be invoked to draw dots.
297292
cpSpaceDebugDrawDotImpl drawDot;
298-
293+
299294
/// Flags that request which things to draw (collision shapes, constraints, contact points).
300295
cpSpaceDebugDrawFlags flags;
301296
/// Outline color passed to the drawing function.
@@ -306,7 +301,9 @@ typedef struct cpSpaceDebugDrawOptions {
306301
cpSpaceDebugColor constraintColor;
307302
/// Color passed to drawing functions for collision points.
308303
cpSpaceDebugColor collisionPointColor;
309-
304+
/// Transform used to transform the things to draw.
305+
cpTransform transform;
306+
310307
/// User defined context pointer passed to all of the callback functions as the 'data' argument.
311308
cpDataPointer data;
312309
} cpSpaceDebugDrawOptions;

0 commit comments

Comments
 (0)