chipmunk 5.2.2 → 5.3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -19
- data/README +67 -60
- data/Rakefile +85 -50
- data/ext/chipmunk/extconf.rb +42 -35
- data/ext/chipmunk/rb_chipmunk.c +250 -125
- data/ext/chipmunk/rb_chipmunk.h +105 -96
- data/ext/chipmunk/rb_cpArbiter.c +253 -225
- data/ext/chipmunk/rb_cpBB.c +210 -174
- data/ext/chipmunk/rb_cpBody.c +504 -347
- data/ext/chipmunk/rb_cpConstraint.c +336 -346
- data/ext/chipmunk/rb_cpShape.c +433 -455
- data/ext/chipmunk/rb_cpSpace.c +711 -544
- data/ext/chipmunk/rb_cpVect.c +346 -321
- data/lib/chipmunk.rb +183 -30
- metadata +12 -66
- data/ext/chipmunk/chipmunk.c +0 -105
- data/ext/chipmunk/cpArbiter.c +0 -274
- data/ext/chipmunk/cpArray.c +0 -128
- data/ext/chipmunk/cpBB.c +0 -47
- data/ext/chipmunk/cpBody.c +0 -188
- data/ext/chipmunk/cpCollision.c +0 -391
- data/ext/chipmunk/cpConstraint.c +0 -54
- data/ext/chipmunk/cpDampedRotarySpring.c +0 -106
- data/ext/chipmunk/cpDampedSpring.c +0 -117
- data/ext/chipmunk/cpGearJoint.c +0 -114
- data/ext/chipmunk/cpGrooveJoint.c +0 -138
- data/ext/chipmunk/cpHashSet.c +0 -253
- data/ext/chipmunk/cpPinJoint.c +0 -117
- data/ext/chipmunk/cpPivotJoint.c +0 -114
- data/ext/chipmunk/cpPolyShape.c +0 -241
- data/ext/chipmunk/cpRatchetJoint.c +0 -128
- data/ext/chipmunk/cpRotaryLimitJoint.c +0 -122
- data/ext/chipmunk/cpShape.c +0 -400
- data/ext/chipmunk/cpSimpleMotor.c +0 -99
- data/ext/chipmunk/cpSlideJoint.c +0 -131
- data/ext/chipmunk/cpSpace.c +0 -899
- data/ext/chipmunk/cpSpaceHash.c +0 -541
- data/ext/chipmunk/cpVect.c +0 -71
- data/ext/chipmunk/include/chipmunk/chipmunk.h +0 -148
- data/ext/chipmunk/include/chipmunk/chipmunk_ffi.h +0 -42
- data/ext/chipmunk/include/chipmunk/chipmunk_types.h +0 -80
- data/ext/chipmunk/include/chipmunk/chipmunk_unsafe.h +0 -54
- data/ext/chipmunk/include/chipmunk/constraints/cpConstraint.h +0 -92
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +0 -46
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +0 -53
- data/ext/chipmunk/include/chipmunk/constraints/cpGearJoint.h +0 -41
- data/ext/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +0 -44
- data/ext/chipmunk/include/chipmunk/constraints/cpPinJoint.h +0 -43
- data/ext/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +0 -42
- data/ext/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +0 -40
- data/ext/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +0 -39
- data/ext/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +0 -37
- data/ext/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +0 -44
- data/ext/chipmunk/include/chipmunk/constraints/util.h +0 -116
- data/ext/chipmunk/include/chipmunk/cpArbiter.h +0 -136
- data/ext/chipmunk/include/chipmunk/cpArray.h +0 -46
- data/ext/chipmunk/include/chipmunk/cpBB.h +0 -74
- data/ext/chipmunk/include/chipmunk/cpBody.h +0 -160
- data/ext/chipmunk/include/chipmunk/cpCollision.h +0 -23
- data/ext/chipmunk/include/chipmunk/cpHashSet.h +0 -82
- data/ext/chipmunk/include/chipmunk/cpPolyShape.h +0 -103
- data/ext/chipmunk/include/chipmunk/cpShape.h +0 -174
- data/ext/chipmunk/include/chipmunk/cpSpace.h +0 -180
- data/ext/chipmunk/include/chipmunk/cpSpaceHash.h +0 -109
- data/ext/chipmunk/include/chipmunk/cpVect.h +0 -157
- data/ext/chipmunk/prime.h +0 -68
- data/lib/chipmunk/version.rb +0 -3
@@ -1,103 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2007 Scott Lembcke
|
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
|
-
|
22
|
-
// Axis structure used by cpPolyShape.
|
23
|
-
typedef struct cpPolyShapeAxis{
|
24
|
-
// normal
|
25
|
-
cpVect n;
|
26
|
-
// distance from origin
|
27
|
-
cpFloat d;
|
28
|
-
} cpPolyShapeAxis;
|
29
|
-
|
30
|
-
// Convex polygon shape structure.
|
31
|
-
typedef struct cpPolyShape{
|
32
|
-
cpShape shape;
|
33
|
-
|
34
|
-
// Vertex and axis lists.
|
35
|
-
int numVerts;
|
36
|
-
cpVect *verts;
|
37
|
-
cpPolyShapeAxis *axes;
|
38
|
-
|
39
|
-
// Transformed vertex and axis lists.
|
40
|
-
cpVect *tVerts;
|
41
|
-
cpPolyShapeAxis *tAxes;
|
42
|
-
} cpPolyShape;
|
43
|
-
|
44
|
-
// Basic allocation functions.
|
45
|
-
cpPolyShape *cpPolyShapeAlloc(void);
|
46
|
-
cpPolyShape *cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset);
|
47
|
-
cpShape *cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset);
|
48
|
-
|
49
|
-
cpPolyShape *cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height);
|
50
|
-
cpShape *cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height);
|
51
|
-
|
52
|
-
// Check that a set of vertexes has a correct winding and that they are convex
|
53
|
-
int cpPolyValidate(cpVect *verts, int numVerts);
|
54
|
-
|
55
|
-
int cpPolyShapeGetNumVerts(cpShape *shape);
|
56
|
-
cpVect cpPolyShapeGetVert(cpShape *shape, int idx);
|
57
|
-
|
58
|
-
// *** inlined utility functions
|
59
|
-
|
60
|
-
// Returns the minimum distance of the polygon to the axis.
|
61
|
-
static inline cpFloat
|
62
|
-
cpPolyShapeValueOnAxis(const cpPolyShape *poly, const cpVect n, const cpFloat d)
|
63
|
-
{
|
64
|
-
cpVect *verts = poly->tVerts;
|
65
|
-
cpFloat min = cpvdot(n, verts[0]);
|
66
|
-
|
67
|
-
int i;
|
68
|
-
for(i=1; i<poly->numVerts; i++)
|
69
|
-
min = cpfmin(min, cpvdot(n, verts[i]));
|
70
|
-
|
71
|
-
return min - d;
|
72
|
-
}
|
73
|
-
|
74
|
-
// Returns true if the polygon contains the vertex.
|
75
|
-
static inline int
|
76
|
-
cpPolyShapeContainsVert(cpPolyShape *poly, cpVect v)
|
77
|
-
{
|
78
|
-
cpPolyShapeAxis *axes = poly->tAxes;
|
79
|
-
|
80
|
-
int i;
|
81
|
-
for(i=0; i<poly->numVerts; i++){
|
82
|
-
cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d;
|
83
|
-
if(dist > 0.0f) return 0;
|
84
|
-
}
|
85
|
-
|
86
|
-
return 1;
|
87
|
-
}
|
88
|
-
|
89
|
-
// Same as cpPolyShapeContainsVert() but ignores faces pointing away from the normal.
|
90
|
-
static inline int
|
91
|
-
cpPolyShapeContainsVertPartial(cpPolyShape *poly, cpVect v, cpVect n)
|
92
|
-
{
|
93
|
-
cpPolyShapeAxis *axes = poly->tAxes;
|
94
|
-
|
95
|
-
int i;
|
96
|
-
for(i=0; i<poly->numVerts; i++){
|
97
|
-
if(cpvdot(axes[i].n, n) < 0.0f) continue;
|
98
|
-
cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d;
|
99
|
-
if(dist > 0.0f) return 0;
|
100
|
-
}
|
101
|
-
|
102
|
-
return 1;
|
103
|
-
}
|
@@ -1,174 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2007 Scott Lembcke
|
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
|
-
|
22
|
-
// Forward declarations required for defining other structs.
|
23
|
-
struct cpShape;
|
24
|
-
struct cpShapeClass;
|
25
|
-
|
26
|
-
typedef struct cpSegmentQueryInfo {
|
27
|
-
struct cpShape *shape; // shape that was hit, NULL if no collision
|
28
|
-
cpFloat t; // Distance along query segment, will always be in the range [0, 1].
|
29
|
-
cpVect n; // normal of hit surface
|
30
|
-
} cpSegmentQueryInfo;
|
31
|
-
|
32
|
-
// Enumeration of shape types.
|
33
|
-
typedef enum cpShapeType{
|
34
|
-
CP_CIRCLE_SHAPE,
|
35
|
-
CP_SEGMENT_SHAPE,
|
36
|
-
CP_POLY_SHAPE,
|
37
|
-
CP_NUM_SHAPES
|
38
|
-
} cpShapeType;
|
39
|
-
|
40
|
-
// Shape class. Holds function pointers and type data.
|
41
|
-
typedef struct cpShapeClass {
|
42
|
-
cpShapeType type;
|
43
|
-
|
44
|
-
// Called by cpShapeCacheBB().
|
45
|
-
cpBB (*cacheData)(struct cpShape *shape, cpVect p, cpVect rot);
|
46
|
-
// Called to by cpShapeDestroy().
|
47
|
-
void (*destroy)(struct cpShape *shape);
|
48
|
-
|
49
|
-
// called by cpShapePointQuery().
|
50
|
-
int (*pointQuery)(struct cpShape *shape, cpVect p);
|
51
|
-
|
52
|
-
// called by cpShapeSegmentQuery()
|
53
|
-
void (*segmentQuery)(struct cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info);
|
54
|
-
} cpShapeClass;
|
55
|
-
|
56
|
-
// Basic shape struct that the others inherit from.
|
57
|
-
typedef struct cpShape{
|
58
|
-
// The "class" of a shape as defined above
|
59
|
-
const cpShapeClass *klass;
|
60
|
-
|
61
|
-
// cpBody that the shape is attached to.
|
62
|
-
cpBody *body;
|
63
|
-
|
64
|
-
// Cached BBox for the shape.
|
65
|
-
cpBB bb;
|
66
|
-
|
67
|
-
// Sensors invoke callbacks, but do not generate collisions
|
68
|
-
int sensor;
|
69
|
-
|
70
|
-
// *** Surface properties.
|
71
|
-
|
72
|
-
// Coefficient of restitution. (elasticity)
|
73
|
-
cpFloat e;
|
74
|
-
// Coefficient of friction.
|
75
|
-
cpFloat u;
|
76
|
-
// Surface velocity used when solving for friction.
|
77
|
-
cpVect surface_v;
|
78
|
-
|
79
|
-
// *** User Definable Fields
|
80
|
-
|
81
|
-
// User defined data pointer for the shape.
|
82
|
-
cpDataPointer data;
|
83
|
-
|
84
|
-
// User defined collision type for the shape.
|
85
|
-
cpCollisionType collision_type;
|
86
|
-
// User defined collision group for the shape.
|
87
|
-
cpGroup group;
|
88
|
-
// User defined layer bitmask for the shape.
|
89
|
-
cpLayers layers;
|
90
|
-
|
91
|
-
// *** Internally Used Fields
|
92
|
-
|
93
|
-
// Unique id used as the hash value.
|
94
|
-
cpHashValue hashid;
|
95
|
-
} cpShape;
|
96
|
-
|
97
|
-
// Low level shape initialization func.
|
98
|
-
cpShape* cpShapeInit(cpShape *shape, const struct cpShapeClass *klass, cpBody *body);
|
99
|
-
|
100
|
-
// Basic destructor functions. (allocation functions are not shared)
|
101
|
-
void cpShapeDestroy(cpShape *shape);
|
102
|
-
void cpShapeFree(cpShape *shape);
|
103
|
-
|
104
|
-
// Cache the BBox of the shape.
|
105
|
-
cpBB cpShapeCacheBB(cpShape *shape);
|
106
|
-
|
107
|
-
// Test if a point lies within a shape.
|
108
|
-
int cpShapePointQuery(cpShape *shape, cpVect p);
|
109
|
-
|
110
|
-
#define CP_DeclareShapeGetter(struct, type, name) type struct##Get##name(cpShape *shape)
|
111
|
-
|
112
|
-
// Circle shape structure.
|
113
|
-
typedef struct cpCircleShape{
|
114
|
-
cpShape shape;
|
115
|
-
|
116
|
-
// Center in body space coordinates
|
117
|
-
cpVect c;
|
118
|
-
// Radius.
|
119
|
-
cpFloat r;
|
120
|
-
|
121
|
-
// Transformed center. (world space coordinates)
|
122
|
-
cpVect tc;
|
123
|
-
} cpCircleShape;
|
124
|
-
|
125
|
-
// Basic allocation functions for cpCircleShape.
|
126
|
-
cpCircleShape *cpCircleShapeAlloc(void);
|
127
|
-
cpCircleShape *cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset);
|
128
|
-
cpShape *cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset);
|
129
|
-
|
130
|
-
CP_DeclareShapeGetter(cpCircleShape, cpVect, Offset);
|
131
|
-
CP_DeclareShapeGetter(cpCircleShape, cpFloat, Radius);
|
132
|
-
|
133
|
-
// Segment shape structure.
|
134
|
-
typedef struct cpSegmentShape{
|
135
|
-
cpShape shape;
|
136
|
-
|
137
|
-
// Endpoints and normal of the segment. (body space coordinates)
|
138
|
-
cpVect a, b, n;
|
139
|
-
// Radius of the segment. (Thickness)
|
140
|
-
cpFloat r;
|
141
|
-
|
142
|
-
// Transformed endpoints and normal. (world space coordinates)
|
143
|
-
cpVect ta, tb, tn;
|
144
|
-
} cpSegmentShape;
|
145
|
-
|
146
|
-
// Basic allocation functions for cpSegmentShape.
|
147
|
-
cpSegmentShape* cpSegmentShapeAlloc(void);
|
148
|
-
cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius);
|
149
|
-
cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius);
|
150
|
-
|
151
|
-
CP_DeclareShapeGetter(cpSegmentShape, cpVect, A);
|
152
|
-
CP_DeclareShapeGetter(cpSegmentShape, cpVect, B);
|
153
|
-
CP_DeclareShapeGetter(cpSegmentShape, cpVect, Normal);
|
154
|
-
CP_DeclareShapeGetter(cpSegmentShape, cpFloat, Radius);
|
155
|
-
|
156
|
-
// For determinism, you can reset the shape id counter.
|
157
|
-
void cpResetShapeIdCounter(void);
|
158
|
-
|
159
|
-
// Directed segment queries against individual shapes.
|
160
|
-
void cpSegmentQueryInfoPrint(cpSegmentQueryInfo *info);
|
161
|
-
|
162
|
-
int cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info);
|
163
|
-
|
164
|
-
static inline cpVect
|
165
|
-
cpSegmentQueryHitPoint(cpVect start, cpVect end, cpSegmentQueryInfo info)
|
166
|
-
{
|
167
|
-
return cpvlerp(start, end, info.t);
|
168
|
-
}
|
169
|
-
|
170
|
-
static inline cpFloat
|
171
|
-
cpSegmentQueryHitDist(cpVect start, cpVect end, cpSegmentQueryInfo info)
|
172
|
-
{
|
173
|
-
return cpvdist(start, end)*info.t;
|
174
|
-
}
|
@@ -1,180 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2007 Scott Lembcke
|
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
|
-
|
22
|
-
struct cpSpace;
|
23
|
-
|
24
|
-
// Number of frames that contact information should persist.
|
25
|
-
extern int cp_contact_persistence;
|
26
|
-
|
27
|
-
// User collision handler function types.
|
28
|
-
typedef int (*cpCollisionBeginFunc)(cpArbiter *arb, struct cpSpace *space, void *data);
|
29
|
-
typedef int (*cpCollisionPreSolveFunc)(cpArbiter *arb, struct cpSpace *space, void *data);
|
30
|
-
typedef void (*cpCollisionPostSolveFunc)(cpArbiter *arb, struct cpSpace *space, void *data);
|
31
|
-
typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, struct cpSpace *space, void *data);
|
32
|
-
|
33
|
-
// Structure for holding collision pair function information.
|
34
|
-
// Used internally.
|
35
|
-
typedef struct cpCollisionHandler {
|
36
|
-
cpCollisionType a;
|
37
|
-
cpCollisionType b;
|
38
|
-
cpCollisionBeginFunc begin;
|
39
|
-
cpCollisionPreSolveFunc preSolve;
|
40
|
-
cpCollisionPostSolveFunc postSolve;
|
41
|
-
cpCollisionSeparateFunc separate;
|
42
|
-
void *data;
|
43
|
-
} cpCollisionHandler;
|
44
|
-
|
45
|
-
#define CP_MAX_CONTACTS_PER_ARBITER 6
|
46
|
-
typedef struct cpContactBufferHeader {
|
47
|
-
int stamp;
|
48
|
-
struct cpContactBufferHeader *next;
|
49
|
-
unsigned int numContacts;
|
50
|
-
} cpContactBufferHeader;
|
51
|
-
|
52
|
-
typedef struct cpSpace{
|
53
|
-
// *** User definable fields
|
54
|
-
|
55
|
-
// Number of iterations to use in the impulse solver to solve contacts.
|
56
|
-
int iterations;
|
57
|
-
|
58
|
-
// Number of iterations to use in the impulse solver to solve elastic collisions.
|
59
|
-
int elasticIterations;
|
60
|
-
|
61
|
-
// Default gravity to supply when integrating rigid body motions.
|
62
|
-
cpVect gravity;
|
63
|
-
|
64
|
-
// Default damping to supply when integrating rigid body motions.
|
65
|
-
cpFloat damping;
|
66
|
-
|
67
|
-
// *** Internally Used Fields
|
68
|
-
|
69
|
-
// When the space is locked, you should not add or remove objects;
|
70
|
-
int locked;
|
71
|
-
|
72
|
-
// Time stamp. Is incremented on every call to cpSpaceStep().
|
73
|
-
int stamp;
|
74
|
-
|
75
|
-
// The static and active shape spatial hashes.
|
76
|
-
cpSpaceHash *staticShapes;
|
77
|
-
cpSpaceHash *activeShapes;
|
78
|
-
|
79
|
-
// List of bodies in the system.
|
80
|
-
cpArray *bodies;
|
81
|
-
|
82
|
-
// List of active arbiters for the impulse solver.
|
83
|
-
cpArray *arbiters, *pooledArbiters;
|
84
|
-
|
85
|
-
// Linked list ring of contact buffers.
|
86
|
-
// Head is the current buffer. Tail is the oldest buffer.
|
87
|
-
// The list points in the direction of tail->head.
|
88
|
-
cpContactBufferHeader *contactBuffersHead, *contactBuffersTail;
|
89
|
-
|
90
|
-
// List of buffers to be free()ed when destroying the space.
|
91
|
-
cpArray *allocatedBuffers;
|
92
|
-
|
93
|
-
// Persistant contact set.
|
94
|
-
cpHashSet *contactSet;
|
95
|
-
|
96
|
-
// List of constraints in the system.
|
97
|
-
cpArray *constraints;
|
98
|
-
|
99
|
-
// Set of collisionpair functions.
|
100
|
-
cpHashSet *collFuncSet;
|
101
|
-
// Default collision handler.
|
102
|
-
cpCollisionHandler defaultHandler;
|
103
|
-
|
104
|
-
cpHashSet *postStepCallbacks;
|
105
|
-
} cpSpace;
|
106
|
-
|
107
|
-
// Basic allocation/destruction functions.
|
108
|
-
cpSpace* cpSpaceAlloc(void);
|
109
|
-
cpSpace* cpSpaceInit(cpSpace *space);
|
110
|
-
cpSpace* cpSpaceNew(void);
|
111
|
-
|
112
|
-
void cpSpaceDestroy(cpSpace *space);
|
113
|
-
void cpSpaceFree(cpSpace *space);
|
114
|
-
|
115
|
-
// Convenience function. Frees all referenced entities. (bodies, shapes and constraints)
|
116
|
-
void cpSpaceFreeChildren(cpSpace *space);
|
117
|
-
|
118
|
-
// Collision handler management functions.
|
119
|
-
void cpSpaceSetDefaultCollisionHandler(
|
120
|
-
cpSpace *space,
|
121
|
-
cpCollisionBeginFunc begin,
|
122
|
-
cpCollisionPreSolveFunc preSolve,
|
123
|
-
cpCollisionPostSolveFunc postSolve,
|
124
|
-
cpCollisionSeparateFunc separate,
|
125
|
-
void *data
|
126
|
-
);
|
127
|
-
void cpSpaceAddCollisionHandler(
|
128
|
-
cpSpace *space,
|
129
|
-
cpCollisionType a, cpCollisionType b,
|
130
|
-
cpCollisionBeginFunc begin,
|
131
|
-
cpCollisionPreSolveFunc preSolve,
|
132
|
-
cpCollisionPostSolveFunc postSolve,
|
133
|
-
cpCollisionSeparateFunc separate,
|
134
|
-
void *data
|
135
|
-
);
|
136
|
-
void cpSpaceRemoveCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b);
|
137
|
-
|
138
|
-
// Add and remove entities from the system.
|
139
|
-
cpShape *cpSpaceAddShape(cpSpace *space, cpShape *shape);
|
140
|
-
cpShape *cpSpaceAddStaticShape(cpSpace *space, cpShape *shape);
|
141
|
-
cpBody *cpSpaceAddBody(cpSpace *space, cpBody *body);
|
142
|
-
cpConstraint *cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint);
|
143
|
-
|
144
|
-
void cpSpaceRemoveShape(cpSpace *space, cpShape *shape);
|
145
|
-
void cpSpaceRemoveStaticShape(cpSpace *space, cpShape *shape);
|
146
|
-
void cpSpaceRemoveBody(cpSpace *space, cpBody *body);
|
147
|
-
void cpSpaceRemoveConstraint(cpSpace *space, cpConstraint *constraint);
|
148
|
-
|
149
|
-
// Post Step function definition
|
150
|
-
typedef void (*cpPostStepFunc)(cpSpace *space, void *obj, void *data);
|
151
|
-
// Register a post step function to be called after cpSpaceStep() has finished.
|
152
|
-
// obj is used a key, you can only register one callback per unique value for obj
|
153
|
-
void cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *obj, void *data);
|
154
|
-
|
155
|
-
// Point query callback function
|
156
|
-
typedef void (*cpSpacePointQueryFunc)(cpShape *shape, void *data);
|
157
|
-
void cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup group, cpSpacePointQueryFunc func, void *data);
|
158
|
-
cpShape *cpSpacePointQueryFirst(cpSpace *space, cpVect point, cpLayers layers, cpGroup group);
|
159
|
-
|
160
|
-
// Segment query callback function
|
161
|
-
typedef void (*cpSpaceSegmentQueryFunc)(cpShape *shape, cpFloat t, cpVect n, void *data);
|
162
|
-
int cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryFunc func, void *data);
|
163
|
-
cpShape *cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSegmentQueryInfo *out);
|
164
|
-
|
165
|
-
// BB query callback function
|
166
|
-
typedef void (*cpSpaceBBQueryFunc)(cpShape *shape, void *data);
|
167
|
-
void cpSpaceBBQuery(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryFunc func, void *data);
|
168
|
-
|
169
|
-
|
170
|
-
// Iterator function for iterating the bodies in a space.
|
171
|
-
typedef void (*cpSpaceBodyIterator)(cpBody *body, void *data);
|
172
|
-
void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIterator func, void *data);
|
173
|
-
|
174
|
-
// Spatial hash management functions.
|
175
|
-
void cpSpaceResizeStaticHash(cpSpace *space, cpFloat dim, int count);
|
176
|
-
void cpSpaceResizeActiveHash(cpSpace *space, cpFloat dim, int count);
|
177
|
-
void cpSpaceRehashStatic(cpSpace *space);
|
178
|
-
|
179
|
-
// Update the space.
|
180
|
-
void cpSpaceStep(cpSpace *space, cpFloat dt);
|