@@ -41,7 +41,6 @@ void b2WakeSolverSet( b2World* world, int setIndex )
41
41
b2SolverSet * disabledSet = world -> solverSetArray + b2_disabledSet ;
42
42
43
43
b2Body * bodies = world -> bodyArrayNew .data ;
44
- b2Contact * contacts = world -> contactArray ;
45
44
46
45
int bodyCount = set -> simsNew .count ;
47
46
for ( int i = 0 ; i < bodyCount ; ++ i )
@@ -69,8 +68,7 @@ void b2WakeSolverSet( b2World* world, int setIndex )
69
68
int edgeIndex = contactKey & 1 ;
70
69
int contactId = contactKey >> 1 ;
71
70
72
- b2CheckIndex ( contacts , contactId );
73
- b2Contact * contact = contacts + contactId ;
71
+ b2Contact * contact = b2ContactArray_Get (& world -> contactArray , contactId );
74
72
75
73
contactKey = contact -> edges [edgeIndex ].nextKey ;
76
74
@@ -94,11 +92,10 @@ void b2WakeSolverSet( b2World* world, int setIndex )
94
92
if ( movedLocalIndex != B2_NULL_INDEX )
95
93
{
96
94
// fix moved element
97
- b2ContactSim * movedContact = disabledSet -> contactsNew .data + localIndex ;
98
- int movedId = movedContact -> contactId ;
99
- b2CheckIndex ( contacts , movedId );
100
- B2_ASSERT ( contacts [movedId ].localIndex == movedLocalIndex );
101
- contacts [movedId ].localIndex = localIndex ;
95
+ b2ContactSim * movedContactSim = disabledSet -> contactsNew .data + localIndex ;
96
+ b2Contact * movedContact = b2ContactArray_Get ( & world -> contactArray , movedContactSim -> contactId );
97
+ B2_ASSERT ( movedContact -> localIndex == movedLocalIndex );
98
+ movedContact -> localIndex = localIndex ;
102
99
}
103
100
}
104
101
}
@@ -109,7 +106,7 @@ void b2WakeSolverSet( b2World* world, int setIndex )
109
106
for ( int i = 0 ; i < contactCount ; ++ i )
110
107
{
111
108
b2ContactSim * contactSim = set -> contactsNew .data + i ;
112
- b2Contact * contact = contacts + contactSim -> contactId ;
109
+ b2Contact * contact = b2ContactArray_Get ( & world -> contactArray , contactSim -> contactId ) ;
113
110
B2_ASSERT ( contact -> flags & b2_contactTouchingFlag );
114
111
B2_ASSERT ( contactSim -> simFlags & b2_simTouchingFlag );
115
112
B2_ASSERT ( contactSim -> manifold .pointCount > 0 );
@@ -196,7 +193,6 @@ void b2TrySleepIsland( b2World* world, int islandId )
196
193
// this shuffles around bodies in the awake set
197
194
{
198
195
b2SolverSet * disabledSet = world -> solverSetArray + b2_disabledSet ;
199
- b2Contact * contacts = world -> contactArray ;
200
196
int bodyId = island -> headBody ;
201
197
while ( bodyId != B2_NULL_INDEX )
202
198
{
@@ -248,8 +244,7 @@ void b2TrySleepIsland( b2World* world, int islandId )
248
244
int contactId = contactKey >> 1 ;
249
245
int edgeIndex = contactKey & 1 ;
250
246
251
- b2CheckIndex ( contacts , contactId );
252
- b2Contact * contact = contacts + contactId ;
247
+ b2Contact * contact = b2ContactArray_Get ( & world -> contactArray , contactId );
253
248
254
249
B2_ASSERT ( contact -> setIndex == b2_awakeSet || contact -> setIndex == b2_disabledSet );
255
250
contactKey = contact -> edges [edgeIndex ].nextKey ;
@@ -289,15 +284,14 @@ void b2TrySleepIsland( b2World* world, int islandId )
289
284
b2ContactSim * disabledContactSim = b2ContactSimArray_Add ( & disabledSet -> contactsNew );
290
285
memcpy ( disabledContactSim , contactSim , sizeof ( b2ContactSim ) );
291
286
292
- int movedContactIndex = b2ContactSimArray_RemoveSwap ( & awakeSet -> contactsNew , localIndex );
293
- if ( movedContactIndex != B2_NULL_INDEX )
287
+ int movedLocalIndex = b2ContactSimArray_RemoveSwap ( & awakeSet -> contactsNew , localIndex );
288
+ if ( movedLocalIndex != B2_NULL_INDEX )
294
289
{
295
290
// fix moved element
296
291
b2ContactSim * movedContactSim = awakeSet -> contactsNew .data + localIndex ;
297
- int movedId = movedContactSim -> contactId ;
298
- b2CheckIndex ( contacts , movedId );
299
- B2_ASSERT ( contacts [movedId ].localIndex == movedContactIndex );
300
- contacts [movedId ].localIndex = localIndex ;
292
+ b2Contact * movedContact = b2ContactArray_Get ( & world -> contactArray , movedContactSim -> contactId );
293
+ B2_ASSERT ( movedContact -> localIndex == movedLocalIndex );
294
+ movedContact -> localIndex = localIndex ;
301
295
}
302
296
}
303
297
@@ -308,12 +302,10 @@ void b2TrySleepIsland( b2World* world, int islandId )
308
302
// move touching contacts
309
303
// this shuffles contacts in the awake set
310
304
{
311
- b2Contact * contacts = world -> contactArray ;
312
305
int contactId = island -> headContact ;
313
306
while ( contactId != B2_NULL_INDEX )
314
307
{
315
- b2CheckIndex ( contacts , contactId );
316
- b2Contact * contact = contacts + contactId ;
308
+ b2Contact * contact = b2ContactArray_Get ( & world -> contactArray , contactId );
317
309
B2_ASSERT ( contact -> setIndex == b2_awakeSet );
318
310
B2_ASSERT ( contact -> islandId == islandId );
319
311
int colorIndex = contact -> colorIndex ;
@@ -329,23 +321,21 @@ void b2TrySleepIsland( b2World* world, int islandId )
329
321
b2ClearBit ( & color -> bodySet , contact -> edges [1 ].bodyId );
330
322
}
331
323
332
- int awakeContactIndex = contact -> localIndex ;
333
- b2ContactSim * awakeContactSim = b2ContactSimArray_Get ( & color -> contactSims , awakeContactIndex );
324
+ int localIndex = contact -> localIndex ;
325
+ b2ContactSim * awakeContactSim = b2ContactSimArray_Get ( & color -> contactSims , localIndex );
334
326
335
327
int sleepContactIndex = sleepSet -> contactsNew .count ;
336
328
b2ContactSim * sleepContactSim = b2ContactSimArray_Add ( & sleepSet -> contactsNew );
337
329
memcpy ( sleepContactSim , awakeContactSim , sizeof ( b2ContactSim ) );
338
330
339
- int movedIndex = b2ContactSimArray_RemoveSwap ( & color -> contactSims , awakeContactIndex );
340
- if ( movedIndex != B2_NULL_INDEX )
331
+ int movedLocalIndex = b2ContactSimArray_RemoveSwap ( & color -> contactSims , localIndex );
332
+ if ( movedLocalIndex != B2_NULL_INDEX )
341
333
{
342
334
// fix moved element
343
- b2ContactSim * movedContactSim = color -> contactSims .data + awakeContactIndex ;
344
- int movedId = movedContactSim -> contactId ;
345
- b2CheckIndex ( contacts , movedId );
346
- b2Contact * movedContact = contacts + movedId ;
347
- B2_ASSERT ( movedContact -> localIndex == movedIndex );
348
- movedContact -> localIndex = awakeContactIndex ;
335
+ b2ContactSim * movedContactSim = color -> contactSims .data + localIndex ;
336
+ b2Contact * movedContact = b2ContactArray_Get ( & world -> contactArray , movedContactSim -> contactId );
337
+ B2_ASSERT ( movedContact -> localIndex == movedLocalIndex );
338
+ movedContact -> localIndex = localIndex ;
349
339
}
350
340
351
341
contact -> setIndex = sleepSetId ;
@@ -474,13 +464,12 @@ void b2MergeSolverSets( b2World* world, int setId1, int setId2 )
474
464
475
465
// transfer contacts
476
466
{
477
- b2Contact * contacts = world -> contactArray ;
478
467
int contactCount = set2 -> contactsNew .count ;
479
468
for ( int i = 0 ; i < contactCount ; ++ i )
480
469
{
481
470
b2ContactSim * contactSrc = set2 -> contactsNew .data + i ;
482
471
483
- b2Contact * contact = contacts + contactSrc -> contactId ;
472
+ b2Contact * contact = b2ContactArray_Get ( & world -> contactArray , contactSrc -> contactId ) ;
484
473
B2_ASSERT ( contact -> setIndex == setId2 );
485
474
contact -> setIndex = setId1 ;
486
475
contact -> localIndex = set1 -> contactsNew .count ;
0 commit comments