Chipmunk2D Pro API Reference
7.0.1
Main Page
Modules
Classes
Files
File List
All
Classes
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Groups
Pages
include
chipmunk
cpSpace.h
1
/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
2
*
3
* Permission is hereby granted, free of charge, to any person obtaining a copy
4
* of this software and associated documentation files (the "Software"), to deal
5
* in the Software without restriction, including without limitation the rights
6
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
* copies of the Software, and to permit persons to whom the Software is
8
* furnished to do so, subject to the following conditions:
9
*
10
* The above copyright notice and this permission notice shall be included in
11
* all copies or substantial portions of the Software.
12
*
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
* SOFTWARE.
20
*/
21
24
25
//MARK: Definitions
26
30
typedef
cpBool
(*
cpCollisionBeginFunc
)(
cpArbiter
*arb,
cpSpace
*space,
cpDataPointer
userData);
33
typedef
cpBool
(*
cpCollisionPreSolveFunc
)(
cpArbiter
*arb,
cpSpace
*space,
cpDataPointer
userData);
35
typedef
void (*
cpCollisionPostSolveFunc
)(
cpArbiter
*arb,
cpSpace
*space,
cpDataPointer
userData);
37
typedef
void (*
cpCollisionSeparateFunc
)(
cpArbiter
*arb,
cpSpace
*space,
cpDataPointer
userData);
38
41
struct
cpCollisionHandler
{
44
const
cpCollisionType
typeA
;
47
const
cpCollisionType
typeB
;
49
cpCollisionBeginFunc
beginFunc
;
52
cpCollisionPreSolveFunc
preSolveFunc
;
55
cpCollisionPostSolveFunc
postSolveFunc
;
57
cpCollisionSeparateFunc
separateFunc
;
59
cpDataPointer
userData
;
60
};
61
62
// TODO: Make timestep a parameter?
63
64
65
//MARK: Memory and Initialization
66
68
CP_EXPORT
cpSpace
*
cpSpaceAlloc
(
void
);
70
CP_EXPORT
cpSpace
*
cpSpaceInit
(
cpSpace
*space);
72
CP_EXPORT
cpSpace
*
cpSpaceNew
(
void
);
73
75
CP_EXPORT
void
cpSpaceDestroy
(
cpSpace
*space);
77
CP_EXPORT
void
cpSpaceFree
(
cpSpace
*space);
78
79
80
//MARK: Properties
81
83
CP_EXPORT
int
cpSpaceGetIterations
(
const
cpSpace
*space);
84
CP_EXPORT
void
cpSpaceSetIterations(
cpSpace
*space,
int
iterations);
85
87
CP_EXPORT
cpVect
cpSpaceGetGravity
(
const
cpSpace
*space);
88
CP_EXPORT
void
cpSpaceSetGravity(
cpSpace
*space,
cpVect
gravity);
89
94
CP_EXPORT
cpFloat
cpSpaceGetDamping
(
const
cpSpace
*space);
95
CP_EXPORT
void
cpSpaceSetDamping(
cpSpace
*space,
cpFloat
damping);
96
99
CP_EXPORT
cpFloat
cpSpaceGetIdleSpeedThreshold
(
const
cpSpace
*space);
100
CP_EXPORT
void
cpSpaceSetIdleSpeedThreshold(
cpSpace
*space,
cpFloat
idleSpeedThreshold);
101
105
CP_EXPORT
cpFloat
cpSpaceGetSleepTimeThreshold
(
const
cpSpace
*space);
106
CP_EXPORT
void
cpSpaceSetSleepTimeThreshold(
cpSpace
*space,
cpFloat
sleepTimeThreshold);
107
112
CP_EXPORT
cpFloat
cpSpaceGetCollisionSlop
(
const
cpSpace
*space);
113
CP_EXPORT
void
cpSpaceSetCollisionSlop(
cpSpace
*space,
cpFloat
collisionSlop);
114
118
CP_EXPORT
cpFloat
cpSpaceGetCollisionBias
(
const
cpSpace
*space);
119
CP_EXPORT
void
cpSpaceSetCollisionBias(
cpSpace
*space,
cpFloat
collisionBias);
120
123
CP_EXPORT
cpTimestamp
cpSpaceGetCollisionPersistence
(
const
cpSpace
*space);
124
CP_EXPORT
void
cpSpaceSetCollisionPersistence(
cpSpace
*space,
cpTimestamp
collisionPersistence);
125
129
CP_EXPORT
cpDataPointer
cpSpaceGetUserData
(
const
cpSpace
*space);
130
CP_EXPORT
void
cpSpaceSetUserData(
cpSpace
*space,
cpDataPointer
userData);
131
134
CP_EXPORT
cpBody
*
cpSpaceGetStaticBody
(
const
cpSpace
*space);
135
138
CP_EXPORT
cpFloat
cpSpaceGetCurrentTimeStep
(
const
cpSpace
*space);
139
141
CP_EXPORT
cpBool
cpSpaceIsLocked
(
cpSpace
*space);
142
143
144
//MARK: Collision Handlers
145
147
CP_EXPORT
cpCollisionHandler
*
cpSpaceAddDefaultCollisionHandler
(
cpSpace
*space);
150
CP_EXPORT
cpCollisionHandler
*
cpSpaceAddCollisionHandler
(
cpSpace
*space,
cpCollisionType
a,
cpCollisionType
b);
152
CP_EXPORT
cpCollisionHandler
*
cpSpaceAddWildcardHandler
(
cpSpace
*space,
cpCollisionType
type);
153
154
155
//MARK: Add/Remove objects
156
159
CP_EXPORT
cpShape
*
cpSpaceAddShape
(
cpSpace
*space,
cpShape
*shape);
161
CP_EXPORT
cpBody
*
cpSpaceAddBody
(
cpSpace
*space,
cpBody
*body);
163
CP_EXPORT
cpConstraint
*
cpSpaceAddConstraint
(
cpSpace
*space,
cpConstraint
*constraint);
164
166
CP_EXPORT
void
cpSpaceRemoveShape
(
cpSpace
*space,
cpShape
*shape);
168
CP_EXPORT
void
cpSpaceRemoveBody
(
cpSpace
*space,
cpBody
*body);
170
CP_EXPORT
void
cpSpaceRemoveConstraint
(
cpSpace
*space,
cpConstraint
*constraint);
171
173
CP_EXPORT
cpBool
cpSpaceContainsShape
(
cpSpace
*space,
cpShape
*shape);
175
CP_EXPORT
cpBool
cpSpaceContainsBody
(
cpSpace
*space,
cpBody
*body);
177
CP_EXPORT
cpBool
cpSpaceContainsConstraint
(
cpSpace
*space,
cpConstraint
*constraint);
178
179
//MARK: Post-Step Callbacks
180
182
typedef
void (*
cpPostStepFunc
)(
cpSpace
*space,
void
*key,
void
*data);
187
CP_EXPORT
cpBool
cpSpaceAddPostStepCallback
(
cpSpace
*space,
cpPostStepFunc
func,
void
*key,
void
*data);
188
189
190
//MARK: Queries
191
192
// TODO: Queries and iterators should take a cpSpace parametery.
193
// TODO: They should also be abortable.
194
196
typedef
void (*
cpSpacePointQueryFunc
)(
cpShape
*shape,
cpVect
point,
cpFloat
distance,
cpVect
gradient,
void
*data);
198
CP_EXPORT
void
cpSpacePointQuery
(
cpSpace
*space,
cpVect
point,
cpFloat
maxDistance,
cpShapeFilter
filter,
cpSpacePointQueryFunc
func,
void
*data);
200
CP_EXPORT
cpShape
*
cpSpacePointQueryNearest
(
cpSpace
*space,
cpVect
point,
cpFloat
maxDistance,
cpShapeFilter
filter,
cpPointQueryInfo
*out);
201
203
typedef
void (*
cpSpaceSegmentQueryFunc
)(
cpShape
*shape,
cpVect
point,
cpVect
normal,
cpFloat
alpha,
void
*data);
205
CP_EXPORT
void
cpSpaceSegmentQuery
(
cpSpace
*space,
cpVect
start,
cpVect
end,
cpFloat
radius,
cpShapeFilter
filter,
cpSpaceSegmentQueryFunc
func,
void
*data);
207
CP_EXPORT
cpShape
*
cpSpaceSegmentQueryFirst
(
cpSpace
*space,
cpVect
start,
cpVect
end,
cpFloat
radius,
cpShapeFilter
filter,
cpSegmentQueryInfo
*out);
208
210
typedef
void (*
cpSpaceBBQueryFunc
)(
cpShape
*shape,
void
*data);
213
CP_EXPORT
void
cpSpaceBBQuery
(
cpSpace
*space,
cpBB
bb,
cpShapeFilter
filter,
cpSpaceBBQueryFunc
func,
void
*data);
214
216
typedef
void (*
cpSpaceShapeQueryFunc
)(
cpShape
*shape,
cpContactPointSet
*points,
void
*data);
218
CP_EXPORT
cpBool
cpSpaceShapeQuery
(
cpSpace
*space,
cpShape
*shape,
cpSpaceShapeQueryFunc
func,
void
*data);
219
220
221
//MARK: Iteration
222
224
typedef
void (*
cpSpaceBodyIteratorFunc
)(
cpBody
*body,
void
*data);
226
CP_EXPORT
void
cpSpaceEachBody
(
cpSpace
*space,
cpSpaceBodyIteratorFunc
func,
void
*data);
227
229
typedef
void (*
cpSpaceShapeIteratorFunc
)(
cpShape
*shape,
void
*data);
231
CP_EXPORT
void
cpSpaceEachShape
(
cpSpace
*space,
cpSpaceShapeIteratorFunc
func,
void
*data);
232
234
typedef
void (*
cpSpaceConstraintIteratorFunc
)(
cpConstraint
*constraint,
void
*data);
236
CP_EXPORT
void
cpSpaceEachConstraint
(
cpSpace
*space,
cpSpaceConstraintIteratorFunc
func,
void
*data);
237
238
239
//MARK: Indexing
240
242
CP_EXPORT
void
cpSpaceReindexStatic
(
cpSpace
*space);
244
CP_EXPORT
void
cpSpaceReindexShape
(
cpSpace
*space,
cpShape
*shape);
246
CP_EXPORT
void
cpSpaceReindexShapesForBody
(
cpSpace
*space,
cpBody
*body);
247
249
CP_EXPORT
void
cpSpaceUseSpatialHash
(
cpSpace
*space,
cpFloat
dim,
int
count);
250
251
252
//MARK: Time Stepping
253
255
CP_EXPORT
void
cpSpaceStep
(
cpSpace
*space,
cpFloat
dt);
256
257
258
//MARK: Debug API
259
260
#ifndef CP_SPACE_DISABLE_DEBUG_API
261
263
typedef
struct
cpSpaceDebugColor
{
264
float
r, g, b, a;
265
}
cpSpaceDebugColor
;
266
268
typedef
void (*
cpSpaceDebugDrawCircleImpl
)(
cpVect
pos,
cpFloat
angle,
cpFloat
radius,
cpSpaceDebugColor
outlineColor,
cpSpaceDebugColor
fillColor,
cpDataPointer
data);
270
typedef
void (*
cpSpaceDebugDrawSegmentImpl
)(
cpVect
a,
cpVect
b,
cpSpaceDebugColor
color,
cpDataPointer
data);
272
typedef
void (*
cpSpaceDebugDrawFatSegmentImpl
)(
cpVect
a,
cpVect
b,
cpFloat
radius,
cpSpaceDebugColor
outlineColor,
cpSpaceDebugColor
fillColor,
cpDataPointer
data);
274
typedef
void (*
cpSpaceDebugDrawPolygonImpl
)(
int
count,
const
cpVect
*verts,
cpFloat
radius,
cpSpaceDebugColor
outlineColor,
cpSpaceDebugColor
fillColor,
cpDataPointer
data);
276
typedef
void (*
cpSpaceDebugDrawDotImpl
)(
cpFloat
size,
cpVect
pos,
cpSpaceDebugColor
color,
cpDataPointer
data);
278
typedef
cpSpaceDebugColor
(*
cpSpaceDebugDrawColorForShapeImpl
)(
cpShape
*shape,
cpDataPointer
data);
279
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;
285
287
typedef
struct
cpSpaceDebugDrawOptions
{
289
cpSpaceDebugDrawCircleImpl
drawCircle
;
291
cpSpaceDebugDrawSegmentImpl
drawSegment
;
293
cpSpaceDebugDrawFatSegmentImpl
drawFatSegment
;
295
cpSpaceDebugDrawPolygonImpl
drawPolygon
;
297
cpSpaceDebugDrawDotImpl
drawDot
;
298
300
cpSpaceDebugDrawFlags
flags
;
302
cpSpaceDebugColor
shapeOutlineColor
;
304
cpSpaceDebugDrawColorForShapeImpl
colorForShape
;
306
cpSpaceDebugColor
constraintColor
;
308
cpSpaceDebugColor
collisionPointColor
;
309
311
cpDataPointer
data
;
312
}
cpSpaceDebugDrawOptions
;
313
315
CP_EXPORT
void
cpSpaceDebugDraw
(
cpSpace
*space,
cpSpaceDebugDrawOptions
*options);
316
317
#endif
318
Generated on Thu Jul 2 2015 11:28:11 for Chipmunk2D Pro API Reference by
1.8.3.1