Debian Codegraph @

src/cpSpace.c

raw symbols SCIP
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
22 #include <stdio.h>
23 #include <string.h>
24
25 #include "chipmunk/chipmunk_private.h"cxx . . $ `<file>/include/chipmunk/chipmunk_private.h`/
26
27 //MARK: Contact Set Helpers
28
29 // Equal function for arbiterSet.
30 static cpBoolcxx . . $ cpBool#
31 arbiterSetEqlcxx . . $ arbiterSetEql(55509796b5e69559).(cpShapecxx . . $ cpShape# **shapes, cpArbitercxx . . $ cpArbiter# *arb)
32 {
33 cpShapecxx . . $ cpShape# *a = shapes[0];
34 cpShapecxx . . $ cpShape# *b = shapes[1];
35
36 return ((a == arb->acxx . . $ cpArbiter#a. && b == arb->bcxx . . $ cpArbiter#b.) || (b == arb->acxx . . $ cpArbiter#a. && a == arb->bcxx . . $ cpArbiter#b.));
37 }
38
39 //MARK: Collision Handler Set HelperFunctions
40
41 // Equals function for collisionHandlers.
42 static cpBoolcxx . . $ cpBool#
43 handlerSetEqlcxx . . $ handlerSetEql(19378d3bee5ab427).(cpCollisionHandlercxx . . $ cpCollisionHandler# *check, cpCollisionHandlercxx . . $ cpCollisionHandler# *pair)
44 {
45 return (
46 (check->typeAcxx . . $ cpCollisionHandler#typeA. == pair->typeAcxx . . $ cpCollisionHandler#typeA. && check->typeBcxx . . $ cpCollisionHandler#typeB. == pair->typeBcxx . . $ cpCollisionHandler#typeB.) ||
47 (check->typeBcxx . . $ cpCollisionHandler#typeB. == pair->typeAcxx . . $ cpCollisionHandler#typeA. && check->typeAcxx . . $ cpCollisionHandler#typeA. == pair->typeBcxx . . $ cpCollisionHandler#typeB.)
48 );
49 }
50
51 // Transformation function for collisionHandlers.
52 static void *
53 handlerSetTranscxx . . $ handlerSetTrans(b99d6a7f1d77708e).(cpCollisionHandlercxx . . $ cpCollisionHandler# *handler, void *unused)
54 {
55 cpCollisionHandlercxx . . $ cpCollisionHandler# *copy = (cpCollisionHandlercxx . . $ cpCollisionHandler# *)cpcalloccxx . . $ `include/chipmunk/chipmunk.h:72:10`!(1, sizeof(cpCollisionHandlercxx . . $ cpCollisionHandler#));
56 memcpycxx . . $ memcpy(cc817cb175f282d).(copy, handler, sizeof(cpCollisionHandlercxx . . $ cpCollisionHandler#));
57
58 return copy;
59 }
60
61 //MARK: Misc Helper Funcs
62
63 // Default collision functions.
64
65 static cpBoolcxx . . $ cpBool#
66 DefaultBegincxx . . $ DefaultBegin(46926bbb19d93a13).(cpArbitercxx . . $ cpArbiter# *arb, cpSpacecxx . . $ cpSpace# *space, void *data){
67 cpBoolcxx . . $ cpBool# retA = cpArbiterCallWildcardBeginAcxx . . $ cpArbiterCallWildcardBeginA(e9b4df504d3a695b).(arb, space);
68 cpBoolcxx . . $ cpBool# retB = cpArbiterCallWildcardBeginBcxx . . $ cpArbiterCallWildcardBeginB(e9b4df504d3a695b).(arb, space);
69 return retA && retB;
70 }
71
72 static cpBoolcxx . . $ cpBool#
73 DefaultPreSolvecxx . . $ DefaultPreSolve(46926bbb19d93a13).(cpArbitercxx . . $ cpArbiter# *arb, cpSpacecxx . . $ cpSpace# *space, void *data){
74 cpBoolcxx . . $ cpBool# retA = cpArbiterCallWildcardPreSolveAcxx . . $ cpArbiterCallWildcardPreSolveA(e9b4df504d3a695b).(arb, space);
75 cpBoolcxx . . $ cpBool# retB = cpArbiterCallWildcardPreSolveBcxx . . $ cpArbiterCallWildcardPreSolveB(e9b4df504d3a695b).(arb, space);
76 return retA && retB;
77 }
78
79 static void
80 DefaultPostSolvecxx . . $ DefaultPostSolve(429dfc06831dcc40).(cpArbitercxx . . $ cpArbiter# *arb, cpSpacecxx . . $ cpSpace# *space, void *data){
81 cpArbiterCallWildcardPostSolveAcxx . . $ cpArbiterCallWildcardPostSolveA(7ad66ffa3c0c87dd).(arb, space);
82 cpArbiterCallWildcardPostSolveBcxx . . $ cpArbiterCallWildcardPostSolveB(7ad66ffa3c0c87dd).(arb, space);
83 }
84
85 static void
86 DefaultSeparatecxx . . $ DefaultSeparate(429dfc06831dcc40).(cpArbitercxx . . $ cpArbiter# *arb, cpSpacecxx . . $ cpSpace# *space, void *data){
87 cpArbiterCallWildcardSeparateAcxx . . $ cpArbiterCallWildcardSeparateA(7ad66ffa3c0c87dd).(arb, space);
88 cpArbiterCallWildcardSeparateBcxx . . $ cpArbiterCallWildcardSeparateB(7ad66ffa3c0c87dd).(arb, space);
89 }
90
91 // Use the wildcard identifier since the default handler should never match any type pair.
92 static cpCollisionHandlercxx . . $ cpCollisionHandler# cpCollisionHandlerDefaultcxx . . $ cpCollisionHandlerDefault. = {
93 CP_WILDCARD_COLLISION_TYPEcxx . . $ `include/chipmunk/chipmunk_types.h:238:10`!, CP_WILDCARD_COLLISION_TYPEcxx . . $ `include/chipmunk/chipmunk_types.h:238:10`!,
94 DefaultBegincxx . . $ DefaultBegin(46926bbb19d93a13)., DefaultPreSolvecxx . . $ DefaultPreSolve(46926bbb19d93a13)., DefaultPostSolvecxx . . $ DefaultPostSolve(429dfc06831dcc40)., DefaultSeparatecxx . . $ DefaultSeparate(429dfc06831dcc40)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!
95 };
96
97 static cpBoolcxx . . $ cpBool# AlwaysCollidecxx . . $ AlwaysCollide(46926bbb19d93a13).(cpArbitercxx . . $ cpArbiter# *arb, cpSpacecxx . . $ cpSpace# *space, void *data){return cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!;}
98 static void DoNothingcxx . . $ DoNothing(429dfc06831dcc40).(cpArbitercxx . . $ cpArbiter# *arb, cpSpacecxx . . $ cpSpace# *space, void *data){}
99
100 cpCollisionHandlercxx . . $ cpCollisionHandler# cpCollisionHandlerDoNothingcxx . . $ cpCollisionHandlerDoNothing. = {
101 CP_WILDCARD_COLLISION_TYPEcxx . . $ `include/chipmunk/chipmunk_types.h:238:10`!, CP_WILDCARD_COLLISION_TYPEcxx . . $ `include/chipmunk/chipmunk_types.h:238:10`!,
102 AlwaysCollidecxx . . $ AlwaysCollide(46926bbb19d93a13)., AlwaysCollidecxx . . $ AlwaysCollide(46926bbb19d93a13)., DoNothingcxx . . $ DoNothing(429dfc06831dcc40)., DoNothingcxx . . $ DoNothing(429dfc06831dcc40)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!
103 };
104
105 // function to get the estimated velocity of a shape for the cpBBTree.
106 static cpVectcxx . . $ cpVect# ShapeVelocityFunccxx . . $ ShapeVelocityFunc(6264bca344117c55).(cpShapecxx . . $ cpShape# *shape){return shape->bodycxx . . $ cpShape#body.->vcxx . . $ cpBody#v.;}
107
108 // Used for disposing of collision handlers.
109 static void FreeWrapcxx . . $ FreeWrap(6c58c5e2437d25a2).(void *ptr, void *unused){cpfreecxx . . $ `include/chipmunk/chipmunk.h:82:10`!(ptr);}
110
111 //MARK: Memory Management Functions
112
113 cpSpacecxx . . $ cpSpace# *
114 cpSpaceAlloccxx . . $ cpSpaceAlloc(1f0082e822a7ce76).(void)
115 {
116 return (cpSpacecxx . . $ cpSpace# *)cpcalloccxx . . $ `include/chipmunk/chipmunk.h:72:10`!(1, sizeof(cpSpacecxx . . $ cpSpace#));
117 }
118
119 cpSpacecxx . . $ cpSpace#*
120 cpSpaceInitcxx . . $ cpSpaceInit(179ace4a7c88b215).(cpSpacecxx . . $ cpSpace# *space)
121 {
122 #ifndef NDEBUGcxx . . $ `<built-in>:413:9`!
123 static cpBool done = cpFalse;
124 if(!done){
125 printf("Initializing cpSpace - Chipmunk v%s (Debug Enabled)\n", cpVersionString);
126 printf("Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks\n");
127 done = cpTrue;
128 }
129 #endif
130
131 space->iterationscxx . . $ cpSpace#iterations. = 10;
132
133 space->gravitycxx . . $ cpSpace#gravity. = cpvzerocxx . . $ cpvzero.;
134 space->dampingcxx . . $ cpSpace#damping. = 1.0f;
135
136 space->collisionSlopcxx . . $ cpSpace#collisionSlop. = 0.1f;
137 space->collisionBiascxx . . $ cpSpace#collisionBias. = cpfpowcxx . . $ `include/chipmunk/chipmunk_types.h:75:10`!(1.0f - 0.1f, 60.0f);
138 space->collisionPersistencecxx . . $ cpSpace#collisionPersistence. = 3;
139
140 space->lockedcxx . . $ cpSpace#locked. = 0;
141 space->stampcxx . . $ cpSpace#stamp. = 0;
142
143 space->shapeIDCountercxx . . $ cpSpace#shapeIDCounter. = 0;
144 space->staticShapescxx . . $ cpSpace#staticShapes. = cpBBTreeNewcxx . . $ cpBBTreeNew(ccce0ca6945a4614).((cpSpatialIndexBBFunccxx . . $ cpSpatialIndexBBFunc#)cpShapeGetBBcxx . . $ cpShapeGetBB(44a9343cdf942fdb)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
145 space->dynamicShapescxx . . $ cpSpace#dynamicShapes. = cpBBTreeNewcxx . . $ cpBBTreeNew(ccce0ca6945a4614).((cpSpatialIndexBBFunccxx . . $ cpSpatialIndexBBFunc#)cpShapeGetBBcxx . . $ cpShapeGetBB(44a9343cdf942fdb)., space->staticShapescxx . . $ cpSpace#staticShapes.);
146 cpBBTreeSetVelocityFunccxx . . $ cpBBTreeSetVelocityFunc(770501a3255b33f).(space->dynamicShapescxx . . $ cpSpace#dynamicShapes., (cpBBTreeVelocityFunccxx . . $ cpBBTreeVelocityFunc#)ShapeVelocityFunccxx . . $ ShapeVelocityFunc(6264bca344117c55).);
147
148 space->allocatedBufferscxx . . $ cpSpace#allocatedBuffers. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
149
150 space->dynamicBodiescxx . . $ cpSpace#dynamicBodies. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
151 space->staticBodiescxx . . $ cpSpace#staticBodies. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
152 space->sleepingComponentscxx . . $ cpSpace#sleepingComponents. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
153 space->rousedBodiescxx . . $ cpSpace#rousedBodies. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
154
155 space->sleepTimeThresholdcxx . . $ cpSpace#sleepTimeThreshold. = INFINITYcxx . . $ `<external>/11263917310783833665/math.h:93:12`!;
156 space->idleSpeedThresholdcxx . . $ cpSpace#idleSpeedThreshold. = 0.0f;
157
158 space->arbiterscxx . . $ cpSpace#arbiters. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
159 space->pooledArbiterscxx . . $ cpSpace#pooledArbiters. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
160
161 space->contactBuffersHeadcxx . . $ cpSpace#contactBuffersHead. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
162 space->cachedArbiterscxx . . $ cpSpace#cachedArbiters. = cpHashSetNewcxx . . $ cpHashSetNew(1aa2f270b6b730e1).(0, (cpHashSetEqlFunccxx . . $ cpHashSetEqlFunc#)arbiterSetEqlcxx . . $ arbiterSetEql(55509796b5e69559).);
163
164 space->constraintscxx . . $ cpSpace#constraints. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
165
166 space->usesWildcardscxx . . $ cpSpace#usesWildcards. = cpFalsecxx . . $ `include/chipmunk/chipmunk_types.h:188:10`!;
167 memcpycxx . . $ memcpy(cc817cb175f282d).(&space->defaultHandlercxx . . $ cpSpace#defaultHandler., &cpCollisionHandlerDoNothingcxx . . $ cpCollisionHandlerDoNothing., sizeof(cpCollisionHandlercxx . . $ cpCollisionHandler#));
168 space->collisionHandlerscxx . . $ cpSpace#collisionHandlers. = cpHashSetNewcxx . . $ cpHashSetNew(1aa2f270b6b730e1).(0, (cpHashSetEqlFunccxx . . $ cpHashSetEqlFunc#)handlerSetEqlcxx . . $ handlerSetEql(19378d3bee5ab427).);
169
170 space->postStepCallbackscxx . . $ cpSpace#postStepCallbacks. = cpArrayNewcxx . . $ cpArrayNew(f90d83c90697c3ae).(0);
171 space->skipPostStepcxx . . $ cpSpace#skipPostStep. = cpFalsecxx . . $ `include/chipmunk/chipmunk_types.h:188:10`!;
172
173 cpBodycxx . . $ cpBody# *staticBody = cpBodyInitcxx . . $ cpBodyInit(5f20355d40defd9e).(&space->_staticBodycxx . . $ cpSpace#_staticBody., 0.0f, 0.0f);
174 cpBodySetTypecxx . . $ cpBodySetType(f2bd8afc8ccfe52).(staticBody, CP_BODY_TYPE_STATICcxx . . $ CP_BODY_TYPE_STATIC.);
175 cpSpaceSetStaticBodycxx . . $ cpSpaceSetStaticBody(f865e61ac2c3a7c6).(space, staticBody);
176
177 return space;
178 }
179
180 cpSpacecxx . . $ cpSpace#*
181 cpSpaceNewcxx . . $ cpSpaceNew(1f0082e822a7ce76).(void)
182 {
183 return cpSpaceInitcxx . . $ cpSpaceInit(179ace4a7c88b215).(cpSpaceAlloccxx . . $ cpSpaceAlloc(1f0082e822a7ce76).());
184 }
185
186 static void cpBodyActivateWrapcxx . . $ cpBodyActivateWrap(3eac74103e9ce6d).(cpBodycxx . . $ cpBody# *body, void *unused){cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(body);}
187
188 void
189 cpSpaceDestroycxx . . $ cpSpaceDestroy(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
190 {
191 cpSpaceEachBodycxx . . $ cpSpaceEachBody(ac08ffee037ef35).(space, (cpSpaceBodyIteratorFunccxx . . $ cpSpaceBodyIteratorFunc#)cpBodyActivateWrapcxx . . $ cpBodyActivateWrap(3eac74103e9ce6d)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
192
193 cpSpatialIndexFreecxx . . $ cpSpatialIndexFree(4404d1a49466a4e0).(space->staticShapescxx . . $ cpSpace#staticShapes.);
194 cpSpatialIndexFreecxx . . $ cpSpatialIndexFree(4404d1a49466a4e0).(space->dynamicShapescxx . . $ cpSpace#dynamicShapes.);
195
196 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->dynamicBodiescxx . . $ cpSpace#dynamicBodies.);
197 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->staticBodiescxx . . $ cpSpace#staticBodies.);
198 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->sleepingComponentscxx . . $ cpSpace#sleepingComponents.);
199 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->rousedBodiescxx . . $ cpSpace#rousedBodies.);
200
201 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->constraintscxx . . $ cpSpace#constraints.);
202
203 cpHashSetFreecxx . . $ cpHashSetFree(a5aef454cd7046d4).(space->cachedArbiterscxx . . $ cpSpace#cachedArbiters.);
204
205 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->arbiterscxx . . $ cpSpace#arbiters.);
206 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->pooledArbiterscxx . . $ cpSpace#pooledArbiters.);
207
208 if(space->allocatedBufferscxx . . $ cpSpace#allocatedBuffers.){
209 cpArrayFreeEachcxx . . $ cpArrayFreeEach(d583da02e3252d4f).(space->allocatedBufferscxx . . $ cpSpace#allocatedBuffers., cpfreecxx . . $ `include/chipmunk/chipmunk.h:82:10`!);
210 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->allocatedBufferscxx . . $ cpSpace#allocatedBuffers.);
211 }
212
213 if(space->postStepCallbackscxx . . $ cpSpace#postStepCallbacks.){
214 cpArrayFreeEachcxx . . $ cpArrayFreeEach(d583da02e3252d4f).(space->postStepCallbackscxx . . $ cpSpace#postStepCallbacks., cpfreecxx . . $ `include/chipmunk/chipmunk.h:82:10`!);
215 cpArrayFreecxx . . $ cpArrayFree(9f115453462bfa05).(space->postStepCallbackscxx . . $ cpSpace#postStepCallbacks.);
216 }
217
218 if(space->collisionHandlerscxx . . $ cpSpace#collisionHandlers.) cpHashSetEachcxx . . $ cpHashSetEach(3ff8996736d46a4d).(space->collisionHandlerscxx . . $ cpSpace#collisionHandlers., FreeWrapcxx . . $ FreeWrap(6c58c5e2437d25a2)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
219 cpHashSetFreecxx . . $ cpHashSetFree(a5aef454cd7046d4).(space->collisionHandlerscxx . . $ cpSpace#collisionHandlers.);
220 }
221
222 void
223 cpSpaceFreecxx . . $ cpSpaceFree(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
224 {
225 if(space){
226 cpSpaceDestroycxx . . $ cpSpaceDestroy(728b9c9a69722ef8).(space);
227 cpfreecxx . . $ `include/chipmunk/chipmunk.h:82:10`!(space);
228 }
229 }
230
231
232 //MARK: Basic properties:
233
234 int
235 cpSpaceGetIterationscxx . . $ cpSpaceGetIterations(8ed9d750ed259745).(const cpSpacecxx . . $ cpSpace# *space)
236 {
237 return space->iterationscxx . . $ cpSpace#iterations.;
238 }
239
240 void
241 cpSpaceSetIterationscxx . . $ cpSpaceSetIterations(3274f250b6e81e27).(cpSpacecxx . . $ cpSpace# *space, int iterations)
242 {
243 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(iterations > 0, "Iterations must be positive and non-zero.");
244 space->iterationscxx . . $ cpSpace#iterations. = iterations;
245 }
246
247 cpVectcxx . . $ cpVect#
248 cpSpaceGetGravitycxx . . $ cpSpaceGetGravity(9a5a38e87209f086).(const cpSpacecxx . . $ cpSpace# *space)
249 {
250 return space->gravitycxx . . $ cpSpace#gravity.;
251 }
252
253 void
254 cpSpaceSetGravitycxx . . $ cpSpaceSetGravity(7561685522e3e327).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# gravity)
255 {
256 space->gravitycxx . . $ cpSpace#gravity. = gravity;
257
258 // Wake up all of the bodies since the gravity changed.
259 cpArraycxx . . $ cpArray# *components = space->sleepingComponentscxx . . $ cpSpace#sleepingComponents.;
260 for(int i=0; i<components->numcxx . . $ cpArray#num.; i++){
261 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).((cpBodycxx . . $ cpBody# *)components->arrcxx . . $ cpArray#arr.[i]);
262 }
263 }
264
265 cpFloatcxx . . $ cpFloat#
266 cpSpaceGetDampingcxx . . $ cpSpaceGetDamping(f2dd6279e77f9c6b).(const cpSpacecxx . . $ cpSpace# *space)
267 {
268 return space->dampingcxx . . $ cpSpace#damping.;
269 }
270
271 void
272 cpSpaceSetDampingcxx . . $ cpSpaceSetDamping(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, cpFloatcxx . . $ cpFloat# damping)
273 {
274 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(damping >= 0.0, "Damping must be positive.");
275 space->dampingcxx . . $ cpSpace#damping. = damping;
276 }
277
278 cpFloatcxx . . $ cpFloat#
279 cpSpaceGetIdleSpeedThresholdcxx . . $ cpSpaceGetIdleSpeedThreshold(f2dd6279e77f9c6b).(const cpSpacecxx . . $ cpSpace# *space)
280 {
281 return space->idleSpeedThresholdcxx . . $ cpSpace#idleSpeedThreshold.;
282 }
283
284 void
285 cpSpaceSetIdleSpeedThresholdcxx . . $ cpSpaceSetIdleSpeedThreshold(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, cpFloatcxx . . $ cpFloat# idleSpeedThreshold)
286 {
287 space->idleSpeedThresholdcxx . . $ cpSpace#idleSpeedThreshold. = idleSpeedThreshold;
288 }
289
290 cpFloatcxx . . $ cpFloat#
291 cpSpaceGetSleepTimeThresholdcxx . . $ cpSpaceGetSleepTimeThreshold(f2dd6279e77f9c6b).(const cpSpacecxx . . $ cpSpace# *space)
292 {
293 return space->sleepTimeThresholdcxx . . $ cpSpace#sleepTimeThreshold.;
294 }
295
296 void
297 cpSpaceSetSleepTimeThresholdcxx . . $ cpSpaceSetSleepTimeThreshold(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, cpFloatcxx . . $ cpFloat# sleepTimeThreshold)
298 {
299 space->sleepTimeThresholdcxx . . $ cpSpace#sleepTimeThreshold. = sleepTimeThreshold;
300 }
301
302 cpFloatcxx . . $ cpFloat#
303 cpSpaceGetCollisionSlopcxx . . $ cpSpaceGetCollisionSlop(f2dd6279e77f9c6b).(const cpSpacecxx . . $ cpSpace# *space)
304 {
305 return space->collisionSlopcxx . . $ cpSpace#collisionSlop.;
306 }
307
308 void
309 cpSpaceSetCollisionSlopcxx . . $ cpSpaceSetCollisionSlop(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, cpFloatcxx . . $ cpFloat# collisionSlop)
310 {
311 space->collisionSlopcxx . . $ cpSpace#collisionSlop. = collisionSlop;
312 }
313
314 cpFloatcxx . . $ cpFloat#
315 cpSpaceGetCollisionBiascxx . . $ cpSpaceGetCollisionBias(f2dd6279e77f9c6b).(const cpSpacecxx . . $ cpSpace# *space)
316 {
317 return space->collisionBiascxx . . $ cpSpace#collisionBias.;
318 }
319
320 void
321 cpSpaceSetCollisionBiascxx . . $ cpSpaceSetCollisionBias(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, cpFloatcxx . . $ cpFloat# collisionBias)
322 {
323 space->collisionBiascxx . . $ cpSpace#collisionBias. = collisionBias;
324 }
325
326 cpTimestampcxx . . $ cpTimestamp#
327 cpSpaceGetCollisionPersistencecxx . . $ cpSpaceGetCollisionPersistence(3a68c96823a9c00d).(const cpSpacecxx . . $ cpSpace# *space)
328 {
329 return space->collisionPersistencecxx . . $ cpSpace#collisionPersistence.;
330 }
331
332 void
333 cpSpaceSetCollisionPersistencecxx . . $ cpSpaceSetCollisionPersistence(3c4258fb13ce0e31).(cpSpacecxx . . $ cpSpace# *space, cpTimestampcxx . . $ cpTimestamp# collisionPersistence)
334 {
335 space->collisionPersistencecxx . . $ cpSpace#collisionPersistence. = collisionPersistence;
336 }
337
338 cpDataPointercxx . . $ cpDataPointer#
339 cpSpaceGetUserDatacxx . . $ cpSpaceGetUserData(238140da70d6d27a).(const cpSpacecxx . . $ cpSpace# *space)
340 {
341 return space->userDatacxx . . $ cpSpace#userData.;
342 }
343
344 void
345 cpSpaceSetUserDatacxx . . $ cpSpaceSetUserData(2003683f3a860053).(cpSpacecxx . . $ cpSpace# *space, cpDataPointercxx . . $ cpDataPointer# userData)
346 {
347 space->userDatacxx . . $ cpSpace#userData. = userData;
348 }
349
350 cpBodycxx . . $ cpBody# *
351 cpSpaceGetStaticBodycxx . . $ cpSpaceGetStaticBody(d6ad68aaf406e51f).(const cpSpacecxx . . $ cpSpace# *space)
352 {
353 return space->staticBodycxx . . $ cpSpace#staticBody.;
354 }
355
356 cpFloatcxx . . $ cpFloat#
357 cpSpaceGetCurrentTimeStepcxx . . $ cpSpaceGetCurrentTimeStep(f2dd6279e77f9c6b).(const cpSpacecxx . . $ cpSpace# *space)
358 {
359 return space->curr_dtcxx . . $ cpSpace#curr_dt.;
360 }
361
362 void
363 cpSpaceSetStaticBodycxx . . $ cpSpaceSetStaticBody(f865e61ac2c3a7c6).(cpSpacecxx . . $ cpSpace# *space, cpBodycxx . . $ cpBody# *body)
364 {
365 if(space->staticBodycxx . . $ cpSpace#staticBody. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!){
366 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(space->staticBody->shapeList == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "Internal Error: Changing the designated static body while the old one still had shapes attached.");
367 space->staticBodycxx . . $ cpSpace#staticBody.->spacecxx . . $ cpBody#space. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
368 }
369
370 space->staticBodycxx . . $ cpSpace#staticBody. = body;
371 body->spacecxx . . $ cpBody#space. = space;
372 }
373
374 cpBoolcxx . . $ cpBool#
375 cpSpaceIsLockedcxx . . $ cpSpaceIsLocked(29825803ebd828f).(cpSpacecxx . . $ cpSpace# *space)
376 {
377 return (space->lockedcxx . . $ cpSpace#locked. > 0);
378 }
379
380 //MARK: Collision Handler Function Management
381
382 static void
383 cpSpaceUseWildcardDefaultHandlercxx . . $ cpSpaceUseWildcardDefaultHandler(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
384 {
385 // Spaces default to using the slightly faster "do nothing" default handler until wildcards are potentially needed.
386 if(!space->usesWildcardscxx . . $ cpSpace#usesWildcards.){
387 space->usesWildcardscxx . . $ cpSpace#usesWildcards. = cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!;
388 memcpycxx . . $ memcpy(cc817cb175f282d).(&space->defaultHandlercxx . . $ cpSpace#defaultHandler., &cpCollisionHandlerDefaultcxx . . $ cpCollisionHandlerDefault., sizeof(cpCollisionHandlercxx . . $ cpCollisionHandler#));
389 }
390 }
391
392 cpCollisionHandlercxx . . $ cpCollisionHandler# *cpSpaceAddDefaultCollisionHandlercxx . . $ cpSpaceAddDefaultCollisionHandler(2524d3282bd1eeab).(cpSpacecxx . . $ cpSpace# *space)
393 {
394 cpSpaceUseWildcardDefaultHandlercxx . . $ cpSpaceUseWildcardDefaultHandler(728b9c9a69722ef8).(space);
395 return &space->defaultHandlercxx . . $ cpSpace#defaultHandler.;
396 }
397
398 cpCollisionHandlercxx . . $ cpCollisionHandler# *cpSpaceAddCollisionHandlercxx . . $ cpSpaceAddCollisionHandler(becf4587622cddc8).(cpSpacecxx . . $ cpSpace# *space, cpCollisionTypecxx . . $ cpCollisionType# a, cpCollisionTypecxx . . $ cpCollisionType# b)
399 {
400 cpHashValuecxx . . $ cpHashValue# hash = CP_HASH_PAIRcxx . . $ `include/chipmunk/chipmunk_private.h:29:9`!(a, b);
401 cpCollisionHandlercxx . . $ cpCollisionHandler# handler = {a, b, DefaultBegincxx . . $ DefaultBegin(46926bbb19d93a13)., DefaultPreSolvecxx . . $ DefaultPreSolve(46926bbb19d93a13)., DefaultPostSolvecxx . . $ DefaultPostSolve(429dfc06831dcc40)., DefaultSeparatecxx . . $ DefaultSeparate(429dfc06831dcc40)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!};
402 return (cpCollisionHandlercxx . . $ cpCollisionHandler#*)cpHashSetInsertcxx . . $ cpHashSetInsert(65a72e7022b62d4d).(space->collisionHandlerscxx . . $ cpSpace#collisionHandlers., hash, &handler, (cpHashSetTransFunccxx . . $ cpHashSetTransFunc#)handlerSetTranscxx . . $ handlerSetTrans(b99d6a7f1d77708e)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
403 }
404
405 cpCollisionHandlercxx . . $ cpCollisionHandler# *
406 cpSpaceAddWildcardHandlercxx . . $ cpSpaceAddWildcardHandler(abdf0636a7c470dd).(cpSpacecxx . . $ cpSpace# *space, cpCollisionTypecxx . . $ cpCollisionType# type)
407 {
408 cpSpaceUseWildcardDefaultHandlercxx . . $ cpSpaceUseWildcardDefaultHandler(728b9c9a69722ef8).(space);
409
410 cpHashValuecxx . . $ cpHashValue# hash = CP_HASH_PAIRcxx . . $ `include/chipmunk/chipmunk_private.h:29:9`!(type, CP_WILDCARD_COLLISION_TYPEcxx . . $ `include/chipmunk/chipmunk_types.h:238:10`!);
411 cpCollisionHandlercxx . . $ cpCollisionHandler# handler = {type, CP_WILDCARD_COLLISION_TYPEcxx . . $ `include/chipmunk/chipmunk_types.h:238:10`!, AlwaysCollidecxx . . $ AlwaysCollide(46926bbb19d93a13)., AlwaysCollidecxx . . $ AlwaysCollide(46926bbb19d93a13)., DoNothingcxx . . $ DoNothing(429dfc06831dcc40)., DoNothingcxx . . $ DoNothing(429dfc06831dcc40)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!};
412 return (cpCollisionHandlercxx . . $ cpCollisionHandler#*)cpHashSetInsertcxx . . $ cpHashSetInsert(65a72e7022b62d4d).(space->collisionHandlerscxx . . $ cpSpace#collisionHandlers., hash, &handler, (cpHashSetTransFunccxx . . $ cpHashSetTransFunc#)handlerSetTranscxx . . $ handlerSetTrans(b99d6a7f1d77708e)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
413 }
414
415
416 //MARK: Body, Shape, and Joint Management
417 cpShapecxx . . $ cpShape# *
418 cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(cpSpacecxx . . $ cpSpace# *space, cpShapecxx . . $ cpShape# *shape)
419 {
420 cpBodycxx . . $ cpBody# *body = shape->bodycxx . . $ cpShape#body.;
421
422 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->space != space, "You have already added this shape to this space. You must not add it a second time.");
423 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(!shape->space, "You have already added this shape to another space. You cannot add it to a second.");
424 // cpAssertHard(body->space == space, "The shape's body must be added to the space before the shape.");
425 cpAssertSpaceUnlockedcxx . . $ `include/chipmunk/chipmunk_private.h:273:9`!(space);
426
427 cpBoolcxx . . $ cpBool# isStatic = (cpBodyGetTypecxx . . $ cpBodyGetType(ea52de4c196d619c).(body) == CP_BODY_TYPE_STATICcxx . . $ CP_BODY_TYPE_STATIC.);
428 if(!isStatic) cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(body);
429 cpBodyAddShapecxx . . $ cpBodyAddShape(84a6c2742ea0ff64).(body, shape);
430
431 shape->hashidcxx . . $ cpShape#hashid. = space->shapeIDCountercxx . . $ cpSpace#shapeIDCounter.++;
432 cpShapeUpdatecxx . . $ cpShapeUpdate(67a5b3d30c6115fd).(shape, body->transformcxx . . $ cpBody#transform.);
433 cpSpatialIndexInsertcxx . . $ cpSpatialIndexInsert(58272ff302488c63).(isStatic ? space->staticShapescxx . . $ cpSpace#staticShapes. : space->dynamicShapescxx . . $ cpSpace#dynamicShapes., shape, shape->hashidcxx . . $ cpShape#hashid.);
434 shape->spacecxx . . $ cpShape#space. = space;
435
436 return shape;
437 }
438
439 cpBodycxx . . $ cpBody# *
440 cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(cpSpacecxx . . $ cpSpace# *space, cpBodycxx . . $ cpBody# *body)
441 {
442 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(body->space != space, "You have already added this body to this space. You must not add it a second time.");
443 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(!body->space, "You have already added this body to another space. You cannot add it to a second.");
444 cpAssertSpaceUnlockedcxx . . $ `include/chipmunk/chipmunk_private.h:273:9`!(space);
445
446 cpArrayPushcxx . . $ cpArrayPush(5027a0abedaf1ddc).(cpSpaceArrayForBodyTypecxx . . $ cpSpaceArrayForBodyType(32c9f2d2827df95e).(space, cpBodyGetTypecxx . . $ cpBodyGetType(ea52de4c196d619c).(body)), body);
447 body->spacecxx . . $ cpBody#space. = space;
448
449 return body;
450 }
451
452 cpConstraintcxx . . $ cpConstraint# *
453 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(cpSpacecxx . . $ cpSpace# *space, cpConstraintcxx . . $ cpConstraint# *constraint)
454 {
455 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(constraint->space != space, "You have already added this constraint to this space. You must not add it a second time.");
456 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(!constraint->space, "You have already added this constraint to another space. You cannot add it to a second.");
457 cpAssertSpaceUnlockedcxx . . $ `include/chipmunk/chipmunk_private.h:273:9`!(space);
458
459 cpBodycxx . . $ cpBody# *a = constraint->acxx . . $ cpConstraint#a., *b = constraint->bcxx . . $ cpConstraint#b.;
460 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(a != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && b != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "Constraint is attached to a NULL body.");
461 // cpAssertHard(a->space == space && b->space == space, "The constraint's bodies must be added to the space before the constraint.");
462
463 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(a);
464 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(b);
465 cpArrayPushcxx . . $ cpArrayPush(5027a0abedaf1ddc).(space->constraintscxx . . $ cpSpace#constraints., constraint);
466
467 // Push onto the heads of the bodies' constraint lists
468 constraint->next_acxx . . $ cpConstraint#next_a. = a->constraintListcxx . . $ cpBody#constraintList.; a->constraintListcxx . . $ cpBody#constraintList. = constraint;
469 constraint->next_bcxx . . $ cpConstraint#next_b. = b->constraintListcxx . . $ cpBody#constraintList.; b->constraintListcxx . . $ cpBody#constraintList. = constraint;
470 constraint->spacecxx . . $ cpConstraint#space. = space;
471
472 return constraint;
473 }
474
475 struct arbiterFilterContextcxx . . $ arbiterFilterContext# {
476 cpSpacecxx . . $ cpSpace# *spacecxx . . $ arbiterFilterContext#space.;
477 cpBodycxx . . $ cpBody# *bodycxx . . $ arbiterFilterContext#body.;
478 cpShapecxx . . $ cpShape# *shapecxx . . $ arbiterFilterContext#shape.;
479 };
480
481 static cpBoolcxx . . $ cpBool#
482 cachedArbitersFiltercxx . . $ cachedArbitersFilter(6d6efcfb715fcc4c).(cpArbitercxx . . $ cpArbiter# *arb, struct arbiterFilterContextcxx . . $ arbiterFilterContext# *context)
483 {
484 cpShapecxx . . $ cpShape# *shape = context->shapecxx . . $ arbiterFilterContext#shape.;
485 cpBodycxx . . $ cpBody# *body = context->bodycxx . . $ arbiterFilterContext#body.;
486
487
488 // Match on the filter shape, or if it's NULL the filter body
489 if(
490 (body == arb->body_acxx . . $ cpArbiter#body_a. && (shape == arb->acxx . . $ cpArbiter#a. || shape == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) ||
491 (body == arb->body_bcxx . . $ cpArbiter#body_b. && (shape == arb->bcxx . . $ cpArbiter#b. || shape == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!))
492 ){
493 // Call separate when removing shapes.
494 if(shape && arb->statecxx . . $ cpArbiter#state. != CP_ARBITER_STATE_CACHEDcxx . . $ CP_ARBITER_STATE_CACHED.){
495 // Invalidate the arbiter since one of the shapes was removed.
496 arb->statecxx . . $ cpArbiter#state. = CP_ARBITER_STATE_INVALIDATEDcxx . . $ CP_ARBITER_STATE_INVALIDATED.;
497
498 cpCollisionHandlercxx . . $ cpCollisionHandler# *handler = arb->handlercxx . . $ cpArbiter#handler.;
499 handler->separateFunccxx . . $ cpCollisionHandler#separateFunc.(arb, context->spacecxx . . $ arbiterFilterContext#space., handler->userDatacxx . . $ cpCollisionHandler#userData.);
500 }
501
502 cpArbiterUnthreadcxx . . $ cpArbiterUnthread(9130529b054e83ea).(arb);
503 cpArrayDeleteObjcxx . . $ cpArrayDeleteObj(5027a0abedaf1ddc).(context->spacecxx . . $ arbiterFilterContext#space.->arbiterscxx . . $ cpSpace#arbiters., arb);
504 cpArrayPushcxx . . $ cpArrayPush(5027a0abedaf1ddc).(context->spacecxx . . $ arbiterFilterContext#space.->pooledArbiterscxx . . $ cpSpace#pooledArbiters., arb);
505
506 return cpFalsecxx . . $ `include/chipmunk/chipmunk_types.h:188:10`!;
507 }
508
509 return cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!;
510 }
511
512 void
513 cpSpaceFilterArbiterscxx . . $ cpSpaceFilterArbiters(c06a35158b422d8c).(cpSpacecxx . . $ cpSpace# *space, cpBodycxx . . $ cpBody# *body, cpShapecxx . . $ cpShape# *filter)
514 {
515 cpSpaceLockcxx . . $ cpSpaceLock(728b9c9a69722ef8).(space); {
516 struct arbiterFilterContextcxx . . $ arbiterFilterContext# context = {space, body, filter};
517 cpHashSetFiltercxx . . $ cpHashSetFilter(ded8e246e9dd8428).(space->cachedArbiterscxx . . $ cpSpace#cachedArbiters., (cpHashSetFilterFunccxx . . $ cpHashSetFilterFunc#)cachedArbitersFiltercxx . . $ cachedArbitersFilter(6d6efcfb715fcc4c)., &context);
518 } cpSpaceUnlockcxx . . $ cpSpaceUnlock(67df6f6b25fde2).(space, cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!);
519 }
520
521 void
522 cpSpaceRemoveShapecxx . . $ cpSpaceRemoveShape(b4590e6760e37cb0).(cpSpacecxx . . $ cpSpace# *space, cpShapecxx . . $ cpShape# *shape)
523 {
524 cpBodycxx . . $ cpBody# *body = shape->bodycxx . . $ cpShape#body.;
525 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(cpSpaceContainsShape(space, shape), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)");
526 cpAssertSpaceUnlockedcxx . . $ `include/chipmunk/chipmunk_private.h:273:9`!(space);
527
528 cpBoolcxx . . $ cpBool# isStatic = (cpBodyGetTypecxx . . $ cpBodyGetType(ea52de4c196d619c).(body) == CP_BODY_TYPE_STATICcxx . . $ CP_BODY_TYPE_STATIC.);
529 if(isStatic){
530 cpBodyActivateStaticcxx . . $ cpBodyActivateStatic(84a6c2742ea0ff64).(body, shape);
531 } else {
532 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(body);
533 }
534
535 cpBodyRemoveShapecxx . . $ cpBodyRemoveShape(84a6c2742ea0ff64).(body, shape);
536 cpSpaceFilterArbiterscxx . . $ cpSpaceFilterArbiters(c06a35158b422d8c).(space, body, shape);
537 cpSpatialIndexRemovecxx . . $ cpSpatialIndexRemove(58272ff302488c63).(isStatic ? space->staticShapescxx . . $ cpSpace#staticShapes. : space->dynamicShapescxx . . $ cpSpace#dynamicShapes., shape, shape->hashidcxx . . $ cpShape#hashid.);
538 shape->spacecxx . . $ cpShape#space. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
539 shape->hashidcxx . . $ cpShape#hashid. = 0;
540 }
541
542 void
543 cpSpaceRemoveBodycxx . . $ cpSpaceRemoveBody(f865e61ac2c3a7c6).(cpSpacecxx . . $ cpSpace# *space, cpBodycxx . . $ cpBody# *body)
544 {
545 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(body != cpSpaceGetStaticBody(space), "Cannot remove the designated static body for the space.");
546 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(cpSpaceContainsBody(space, body), "Cannot remove a body that was not added to the space. (Removed twice maybe?)");
547 // cpAssertHard(body->shapeList == NULL, "Cannot remove a body from the space before removing the bodies attached to it.");
548 // cpAssertHard(body->constraintList == NULL, "Cannot remove a body from the space before removing the constraints attached to it.");
549 cpAssertSpaceUnlockedcxx . . $ `include/chipmunk/chipmunk_private.h:273:9`!(space);
550
551 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(body);
552 // cpSpaceFilterArbiters(space, body, NULL);
553 cpArrayDeleteObjcxx . . $ cpArrayDeleteObj(5027a0abedaf1ddc).(cpSpaceArrayForBodyTypecxx . . $ cpSpaceArrayForBodyType(32c9f2d2827df95e).(space, cpBodyGetTypecxx . . $ cpBodyGetType(ea52de4c196d619c).(body)), body);
554 body->spacecxx . . $ cpBody#space. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
555 }
556
557 void
558 cpSpaceRemoveConstraintcxx . . $ cpSpaceRemoveConstraint(ab426c857162788d).(cpSpacecxx . . $ cpSpace# *space, cpConstraintcxx . . $ cpConstraint# *constraint)
559 {
560 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(cpSpaceContainsConstraint(space, constraint), "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)");
561 cpAssertSpaceUnlockedcxx . . $ `include/chipmunk/chipmunk_private.h:273:9`!(space);
562
563 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(constraint->acxx . . $ cpConstraint#a.);
564 cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(constraint->bcxx . . $ cpConstraint#b.);
565 cpArrayDeleteObjcxx . . $ cpArrayDeleteObj(5027a0abedaf1ddc).(space->constraintscxx . . $ cpSpace#constraints., constraint);
566
567 cpBodyRemoveConstraintcxx . . $ cpBodyRemoveConstraint(f4dd701ccc0b05d0).(constraint->acxx . . $ cpConstraint#a., constraint);
568 cpBodyRemoveConstraintcxx . . $ cpBodyRemoveConstraint(f4dd701ccc0b05d0).(constraint->bcxx . . $ cpConstraint#b., constraint);
569 constraint->spacecxx . . $ cpConstraint#space. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
570 }
571
572 cpBoolcxx . . $ cpBool# cpSpaceContainsShapecxx . . $ cpSpaceContainsShape(f92c9bc9085e319f).(cpSpacecxx . . $ cpSpace# *space, cpShapecxx . . $ cpShape# *shape)
573 {
574 return (shape->spacecxx . . $ cpShape#space. == space);
575 }
576
577 cpBoolcxx . . $ cpBool# cpSpaceContainsBodycxx . . $ cpSpaceContainsBody(89c8d3f7ab1f1024).(cpSpacecxx . . $ cpSpace# *space, cpBodycxx . . $ cpBody# *body)
578 {
579 return (body->spacecxx . . $ cpBody#space. == space);
580 }
581
582 cpBoolcxx . . $ cpBool# cpSpaceContainsConstraintcxx . . $ cpSpaceContainsConstraint(c5f36dc5df8b0359).(cpSpacecxx . . $ cpSpace# *space, cpConstraintcxx . . $ cpConstraint# *constraint)
583 {
584 return (constraint->spacecxx . . $ cpConstraint#space. == space);
585 }
586
587 //MARK: Iteration
588
589 void
590 cpSpaceEachBodycxx . . $ cpSpaceEachBody(ac08ffee037ef35).(cpSpacecxx . . $ cpSpace# *space, cpSpaceBodyIteratorFunccxx . . $ cpSpaceBodyIteratorFunc# func, void *data)
591 {
592 cpSpaceLockcxx . . $ cpSpaceLock(728b9c9a69722ef8).(space); {
593 cpArraycxx . . $ cpArray# *bodies = space->dynamicBodiescxx . . $ cpSpace#dynamicBodies.;
594 for(int i=0; i<bodies->numcxx . . $ cpArray#num.; i++){
595 func((cpBodycxx . . $ cpBody# *)bodies->arrcxx . . $ cpArray#arr.[i], data);
596 }
597
598 cpArraycxx . . $ cpArray# *otherBodies = space->staticBodiescxx . . $ cpSpace#staticBodies.;
599 for(int i=0; i<otherBodies->numcxx . . $ cpArray#num.; i++){
600 func((cpBodycxx . . $ cpBody# *)otherBodies->arrcxx . . $ cpArray#arr.[i], data);
601 }
602
603 cpArraycxx . . $ cpArray# *components = space->sleepingComponentscxx . . $ cpSpace#sleepingComponents.;
604 for(int i=0; i<components->numcxx . . $ cpArray#num.; i++){
605 cpBodycxx . . $ cpBody# *root = (cpBodycxx . . $ cpBody# *)components->arrcxx . . $ cpArray#arr.[i];
606
607 cpBodycxx . . $ cpBody# *body = root;
608 while(body){
609 cpBodycxx . . $ cpBody# *next = body->sleepingcxx . . $ cpBody#sleeping..nextcxx . . $ cpBody#$anonymous_type_0#next.;
610 func(body, data);
611 body = next;
612 }
613 }
614 } cpSpaceUnlockcxx . . $ cpSpaceUnlock(67df6f6b25fde2).(space, cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!);
615 }
616
617 typedef struct spaceShapeContextcxx . . $ spaceShapeContext# {
618 cpSpaceShapeIteratorFunccxx . . $ cpSpaceShapeIteratorFunc# funccxx . . $ spaceShapeContext#func.;
619 void *datacxx . . $ spaceShapeContext#data.;
620 } spaceShapeContextcxx . . $ spaceShapeContext#;
621
622 static void
623 spaceEachShapeIteratorcxx . . $ spaceEachShapeIterator(2ed9daf0d7d4430).(cpShapecxx . . $ cpShape# *shape, spaceShapeContextcxx . . $ spaceShapeContext# *context)
624 {
625 context->funccxx . . $ spaceShapeContext#func.(shape, context->datacxx . . $ spaceShapeContext#data.);
626 }
627
628 void
629 cpSpaceEachShapecxx . . $ cpSpaceEachShape(c89de79254242337).(cpSpacecxx . . $ cpSpace# *space, cpSpaceShapeIteratorFunccxx . . $ cpSpaceShapeIteratorFunc# func, void *data)
630 {
631 cpSpaceLockcxx . . $ cpSpaceLock(728b9c9a69722ef8).(space); {
632 spaceShapeContextcxx . . $ spaceShapeContext# context = {func, data};
633 cpSpatialIndexEachcxx . . $ cpSpatialIndexEach(63a26082660cb28c).(space->dynamicShapescxx . . $ cpSpace#dynamicShapes., (cpSpatialIndexIteratorFunccxx . . $ cpSpatialIndexIteratorFunc#)spaceEachShapeIteratorcxx . . $ spaceEachShapeIterator(2ed9daf0d7d4430)., &context);
634 cpSpatialIndexEachcxx . . $ cpSpatialIndexEach(63a26082660cb28c).(space->staticShapescxx . . $ cpSpace#staticShapes., (cpSpatialIndexIteratorFunccxx . . $ cpSpatialIndexIteratorFunc#)spaceEachShapeIteratorcxx . . $ spaceEachShapeIterator(2ed9daf0d7d4430)., &context);
635 } cpSpaceUnlockcxx . . $ cpSpaceUnlock(67df6f6b25fde2).(space, cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!);
636 }
637
638 void
639 cpSpaceEachConstraintcxx . . $ cpSpaceEachConstraint(b1831c7c46e49bbc).(cpSpacecxx . . $ cpSpace# *space, cpSpaceConstraintIteratorFunccxx . . $ cpSpaceConstraintIteratorFunc# func, void *data)
640 {
641 cpSpaceLockcxx . . $ cpSpaceLock(728b9c9a69722ef8).(space); {
642 cpArraycxx . . $ cpArray# *constraints = space->constraintscxx . . $ cpSpace#constraints.;
643
644 for(int i=0; i<constraints->numcxx . . $ cpArray#num.; i++){
645 func((cpConstraintcxx . . $ cpConstraint# *)constraints->arrcxx . . $ cpArray#arr.[i], data);
646 }
647 } cpSpaceUnlockcxx . . $ cpSpaceUnlock(67df6f6b25fde2).(space, cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!);
648 }
649
650 //MARK: Spatial Index Management
651
652 void
653 cpSpaceReindexStaticcxx . . $ cpSpaceReindexStatic(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
654 {
655 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");
656
657 cpSpatialIndexEachcxx . . $ cpSpatialIndexEach(63a26082660cb28c).(space->staticShapescxx . . $ cpSpace#staticShapes., (cpSpatialIndexIteratorFunccxx . . $ cpSpatialIndexIteratorFunc#)&cpShapeUpdateFunccxx . . $ cpShapeUpdateFunc(ebab24832b4ea92d)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
658 cpSpatialIndexReindexcxx . . $ cpSpatialIndexReindex(4404d1a49466a4e0).(space->staticShapescxx . . $ cpSpace#staticShapes.);
659 }
660
661 void
662 cpSpaceReindexShapecxx . . $ cpSpaceReindexShape(b4590e6760e37cb0).(cpSpacecxx . . $ cpSpace# *space, cpShapecxx . . $ cpShape# *shape)
663 {
664 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");
665
666 cpShapeCacheBBcxx . . $ cpShapeCacheBB(e4bf0be2c162867c).(shape);
667
668 // attempt to rehash the shape in both hashes
669 cpSpatialIndexReindexObjectcxx . . $ cpSpatialIndexReindexObject(58272ff302488c63).(space->dynamicShapescxx . . $ cpSpace#dynamicShapes., shape, shape->hashidcxx . . $ cpShape#hashid.);
670 cpSpatialIndexReindexObjectcxx . . $ cpSpatialIndexReindexObject(58272ff302488c63).(space->staticShapescxx . . $ cpSpace#staticShapes., shape, shape->hashidcxx . . $ cpShape#hashid.);
671 }
672
673 void
674 cpSpaceReindexShapesForBodycxx . . $ cpSpaceReindexShapesForBody(f865e61ac2c3a7c6).(cpSpacecxx . . $ cpSpace# *space, cpBodycxx . . $ cpBody# *body)
675 {
676 CP_BODY_FOREACH_SHAPEcxx . . $ `include/chipmunk/chipmunk_private.h:338:9`!(body, shape) cpSpaceReindexShapecxx . . $ cpSpaceReindexShape(b4590e6760e37cb0).(space, shape);
677 }
678
679
680 static void
681 copyShapescxx . . $ copyShapes(bc13460fab27cb12).(cpShapecxx . . $ cpShape# *shape, cpSpatialIndexcxx . . $ cpSpatialIndex# *index)
682 {
683 cpSpatialIndexInsertcxx . . $ cpSpatialIndexInsert(58272ff302488c63).(index, shape, shape->hashidcxx . . $ cpShape#hashid.);
684 }
685
686 void
687 cpSpaceUseSpatialHashcxx . . $ cpSpaceUseSpatialHash(3cef60747bc5c4ee).(cpSpacecxx . . $ cpSpace# *space, cpFloatcxx . . $ cpFloat# dim, int count)
688 {
689 cpSpatialIndexcxx . . $ cpSpatialIndex# *staticShapes = cpSpaceHashNewcxx . . $ cpSpaceHashNew(6523dc62925bd740).(dim, count, (cpSpatialIndexBBFunccxx . . $ cpSpatialIndexBBFunc#)cpShapeGetBBcxx . . $ cpShapeGetBB(44a9343cdf942fdb)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
690 cpSpatialIndexcxx . . $ cpSpatialIndex# *dynamicShapes = cpSpaceHashNewcxx . . $ cpSpaceHashNew(6523dc62925bd740).(dim, count, (cpSpatialIndexBBFunccxx . . $ cpSpatialIndexBBFunc#)cpShapeGetBBcxx . . $ cpShapeGetBB(44a9343cdf942fdb)., staticShapes);
691
692 cpSpatialIndexEachcxx . . $ cpSpatialIndexEach(63a26082660cb28c).(space->staticShapescxx . . $ cpSpace#staticShapes., (cpSpatialIndexIteratorFunccxx . . $ cpSpatialIndexIteratorFunc#)copyShapescxx . . $ copyShapes(bc13460fab27cb12)., staticShapes);
693 cpSpatialIndexEachcxx . . $ cpSpatialIndexEach(63a26082660cb28c).(space->dynamicShapescxx . . $ cpSpace#dynamicShapes., (cpSpatialIndexIteratorFunccxx . . $ cpSpatialIndexIteratorFunc#)copyShapescxx . . $ copyShapes(bc13460fab27cb12)., dynamicShapes);
694
695 cpSpatialIndexFreecxx . . $ cpSpatialIndexFree(4404d1a49466a4e0).(space->staticShapescxx . . $ cpSpace#staticShapes.);
696 cpSpatialIndexFreecxx . . $ cpSpatialIndexFree(4404d1a49466a4e0).(space->dynamicShapescxx . . $ cpSpace#dynamicShapes.);
697
698 space->staticShapescxx . . $ cpSpace#staticShapes. = staticShapes;
699 space->dynamicShapescxx . . $ cpSpace#dynamicShapes. = dynamicShapes;
700 }