Skip to content

Commit 29b1e8a

Browse files
committed
wip 2
1 parent ec2a473 commit 29b1e8a

18 files changed

Lines changed: 219 additions & 219 deletions

src/Box2D.NET/B2Bodies.cs

Lines changed: 64 additions & 64 deletions
Large diffs are not rendered by default.

src/Box2D.NET/B2ConstraintGraphs.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ internal static void b2AddContactToGraph(B2World world, B2ContactSim contactSim,
176176
}
177177
else
178178
{
179-
B2_ASSERT(bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet);
180-
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType2.b2_awakeSet);
179+
B2_ASSERT(bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet);
180+
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType.b2_awakeSet);
181181

182182
int localIndex = bodyA.localIndex;
183183
newContact.bodySimIndexA = localIndex;
@@ -195,8 +195,8 @@ internal static void b2AddContactToGraph(B2World world, B2ContactSim contactSim,
195195
}
196196
else
197197
{
198-
B2_ASSERT(bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet);
199-
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType2.b2_awakeSet);
198+
B2_ASSERT(bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet);
199+
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType.b2_awakeSet);
200200

201201
int localIndex = bodyB.localIndex;
202202
newContact.bodySimIndexB = localIndex;
@@ -230,7 +230,7 @@ internal static void b2RemoveContactFromGraph(B2World world, int bodyIdA, int bo
230230
// Fix moved contact
231231
int movedId = movedContactSim.contactId;
232232
B2Contact movedContact = b2Array_Get(ref world.contacts, movedId);
233-
B2_ASSERT(movedContact.setIndex == (int)B2SolverSetType2.b2_awakeSet);
233+
B2_ASSERT(movedContact.setIndex == (int)B2SolverSetType.b2_awakeSet);
234234
B2_ASSERT(movedContact.colorIndex == colorIndex);
235235
B2_ASSERT(movedContact.localIndex == movedIndex);
236236
movedContact.localIndex = localIndex;
@@ -343,7 +343,7 @@ internal static void b2RemoveJointFromGraph(B2World world, int bodyIdA, int body
343343
B2JointSim movedJointSim = color.jointSims.data[localIndex];
344344
int movedId = movedJointSim.jointId;
345345
B2Joint movedJoint = b2Array_Get(ref world.joints, movedId);
346-
B2_ASSERT(movedJoint.setIndex == (int)B2SolverSetType2.b2_awakeSet);
346+
B2_ASSERT(movedJoint.setIndex == (int)B2SolverSetType.b2_awakeSet);
347347
B2_ASSERT(movedJoint.colorIndex == colorIndex);
348348
B2_ASSERT(movedJoint.localIndex == movedIndex);
349349
movedJoint.localIndex = localIndex;

src/Box2D.NET/B2ContactSolvers.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ internal static void b2PrepareOverflowContacts(B2StepContext context)
6565

6666
#if DEBUG
6767
B2Body bodyA = bodies[contactSim.bodyIdA];
68-
int validIndexA = bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet ? bodyA.localIndex : B2_NULL_INDEX;
68+
int validIndexA = bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet ? bodyA.localIndex : B2_NULL_INDEX;
6969
B2_ASSERT(indexA == validIndexA);
7070

7171
B2Body bodyB = bodies[contactSim.bodyIdB];
72-
int validIndexB = bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet ? bodyB.localIndex : B2_NULL_INDEX;
72+
int validIndexB = bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet ? bodyB.localIndex : B2_NULL_INDEX;
7373
B2_ASSERT(indexB == validIndexB);
7474
#endif
7575

@@ -174,7 +174,7 @@ internal static void b2WarmStartOverflowContacts(B2StepContext context)
174174
Span<B2ContactConstraint> constraints = color.overflowConstraints;
175175
int contactCount = color.contactSims.count;
176176
B2World world = context.world;
177-
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType2.b2_awakeSet);
177+
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType.b2_awakeSet);
178178
B2BodyState[] states = awakeSet.bodyStates.data;
179179

180180
// This is a dummy state to represent a static body because static bodies don't have a solver body.
@@ -251,7 +251,7 @@ internal static void b2SolveOverflowContacts(B2StepContext context, bool useBias
251251
Span<B2ContactConstraint> constraints = color.overflowConstraints;
252252
int contactCount = color.contactSims.count;
253253
B2World world = context.world;
254-
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType2.b2_awakeSet);
254+
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType.b2_awakeSet);
255255
B2BodyState[] states = awakeSet.bodyStates.data;
256256

257257
float inv_h = context.inv_h;
@@ -416,7 +416,7 @@ internal static void b2ApplyOverflowRestitution(B2StepContext context)
416416
Span<B2ContactConstraint> constraints = color.overflowConstraints;
417417
int contactCount = color.contactSims.count;
418418
B2World world = context.world;
419-
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType2.b2_awakeSet);
419+
B2SolverSet awakeSet = b2Array_Get(ref world.solverSets, (int)B2SolverSetType.b2_awakeSet);
420420
B2BodyState[] states = awakeSet.bodyStates.data;
421421

422422
float threshold = context.world.restitutionThreshold;
@@ -1209,9 +1209,9 @@ internal static void b2PrepareContactsTask(int startIndex, int endIndex, B2StepC
12091209

12101210
#if DEBUG
12111211
B2Body bodyA = bodies[contactSim.bodyIdA];
1212-
int validIndexA = bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet ? bodyA.localIndex : B2_NULL_INDEX;
1212+
int validIndexA = bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet ? bodyA.localIndex : B2_NULL_INDEX;
12131213
B2Body bodyB = bodies[contactSim.bodyIdB];
1214-
int validIndexB = bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet ? bodyB.localIndex : B2_NULL_INDEX;
1214+
int validIndexB = bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet ? bodyB.localIndex : B2_NULL_INDEX;
12151215

12161216
B2_ASSERT(indexA == validIndexA);
12171217
B2_ASSERT(indexB == validIndexB);

src/Box2D.NET/B2Contacts.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,20 @@ public static void b2CreateContact(B2World world, B2Shape shapeA, B2Shape shapeB
171171
B2Body bodyA = b2Array_Get(ref world.bodies, shapeA.bodyId);
172172
B2Body bodyB = b2Array_Get(ref world.bodies, shapeB.bodyId);
173173

174-
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType2.b2_disabledSet && bodyB.setIndex != (int)B2SolverSetType2.b2_disabledSet);
175-
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType2.b2_staticSet || bodyB.setIndex != (int)B2SolverSetType2.b2_staticSet);
174+
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType.b2_disabledSet && bodyB.setIndex != (int)B2SolverSetType.b2_disabledSet);
175+
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType.b2_staticSet || bodyB.setIndex != (int)B2SolverSetType.b2_staticSet);
176176

177177
int setIndex;
178-
if (bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet || bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet)
178+
if (bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet || bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet)
179179
{
180-
setIndex = (int)B2SolverSetType2.b2_awakeSet;
180+
setIndex = (int)B2SolverSetType.b2_awakeSet;
181181
}
182182
else
183183
{
184184
// sleeping and non-touching contacts live in the disabled set
185185
// later if this set is found to be touching then the sleeping
186186
// islands will be linked and the contact moved to the merged island
187-
setIndex = (int)B2SolverSetType2.b2_disabledSet;
187+
setIndex = (int)B2SolverSetType.b2_disabledSet;
188188
}
189189

190190
B2SolverSet set = b2Array_Get(ref world.solverSets, setIndex);
@@ -401,13 +401,13 @@ public static void b2DestroyContact(B2World world, B2Contact contact, bool wakeB
401401
if (contact.colorIndex != B2_NULL_INDEX)
402402
{
403403
// contact is an active constraint
404-
B2_ASSERT(contact.setIndex == (int)B2SolverSetType2.b2_awakeSet);
404+
B2_ASSERT(contact.setIndex == (int)B2SolverSetType.b2_awakeSet);
405405
b2RemoveContactFromGraph(world, bodyIdA, bodyIdB, contact.colorIndex, contact.localIndex);
406406
}
407407
else
408408
{
409409
// contact is non-touching or is sleeping
410-
B2_ASSERT(contact.setIndex != (int)B2SolverSetType2.b2_awakeSet || (contact.flags & (uint)B2ContactFlags.b2_contactTouchingFlag) == 0);
410+
B2_ASSERT(contact.setIndex != (int)B2SolverSetType.b2_awakeSet || (contact.flags & (uint)B2ContactFlags.b2_contactTouchingFlag) == 0);
411411
B2SolverSet set = b2Array_Get(ref world.solverSets, contact.setIndex);
412412

413413
int movedIndex = b2Array_RemoveSwap(ref set.contactSims, contact.localIndex);
@@ -435,7 +435,7 @@ public static void b2DestroyContact(B2World world, B2Contact contact, bool wakeB
435435

436436
internal static B2ContactSim b2GetContactSim(B2World world, B2Contact contact)
437437
{
438-
if (contact.setIndex == (int)B2SolverSetType2.b2_awakeSet && contact.colorIndex != B2_NULL_INDEX)
438+
if (contact.setIndex == (int)B2SolverSetType.b2_awakeSet && contact.colorIndex != B2_NULL_INDEX)
439439
{
440440
// contact lives in constraint graph
441441
B2_ASSERT(0 <= contact.colorIndex && contact.colorIndex < B2_GRAPH_COLOR_COUNT);

src/Box2D.NET/B2DistanceJoints.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ internal static void b2PrepareDistanceJoint(B2JointSim @base, B2StepContext cont
244244
B2Body bodyA = b2Array_Get(ref world.bodies, idA);
245245
B2Body bodyB = b2Array_Get(ref world.bodies, idB);
246246

247-
B2_ASSERT(bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet || bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet);
247+
B2_ASSERT(bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet || bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet);
248248

249249
B2SolverSet setA = b2Array_Get(ref world.solverSets, bodyA.setIndex);
250250
B2SolverSet setB = b2Array_Get(ref world.solverSets, bodyB.setIndex);
@@ -267,8 +267,8 @@ internal static void b2PrepareDistanceJoint(B2JointSim @base, B2StepContext cont
267267

268268
ref B2DistanceJoint joint = ref @base.uj.distanceJoint;
269269

270-
joint.indexA = bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet ? localIndexA : B2_NULL_INDEX;
271-
joint.indexB = bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet ? localIndexB : B2_NULL_INDEX;
270+
joint.indexA = bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet ? localIndexA : B2_NULL_INDEX;
271+
joint.indexB = bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet ? localIndexB : B2_NULL_INDEX;
272272

273273
// initial anchors in world space
274274
joint.anchorA = b2RotateVector(bodySimA.transform.q, b2Sub(@base.localFrameA.p, bodySimA.localCenter));

src/Box2D.NET/B2Islands.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class B2Islands
2828

2929
public static B2Island b2CreateIsland(B2World world, int setIndex)
3030
{
31-
B2_ASSERT(setIndex == (int)B2SolverSetType2.b2_awakeSet || setIndex >= (int)B2SolverSetType2.b2_firstSleepingSet);
31+
B2_ASSERT(setIndex == (int)B2SolverSetType.b2_awakeSet || setIndex >= (int)B2SolverSetType.b2_firstSleepingSet);
3232

3333
int islandId = b2AllocId(world.islandIdPool);
3434

@@ -283,17 +283,17 @@ internal static void b2LinkContact(B2World world, B2Contact contact)
283283
B2Body bodyA = b2Array_Get(ref world.bodies, bodyIdA);
284284
B2Body bodyB = b2Array_Get(ref world.bodies, bodyIdB);
285285

286-
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType2.b2_disabledSet && bodyB.setIndex != (int)B2SolverSetType2.b2_disabledSet);
287-
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType2.b2_staticSet || bodyB.setIndex != (int)B2SolverSetType2.b2_staticSet);
286+
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType.b2_disabledSet && bodyB.setIndex != (int)B2SolverSetType.b2_disabledSet);
287+
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType.b2_staticSet || bodyB.setIndex != (int)B2SolverSetType.b2_staticSet);
288288

289289
// Wake bodyB if bodyA is awake and bodyB is sleeping
290-
if (bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet && bodyB.setIndex >= (int)B2SolverSetType2.b2_firstSleepingSet)
290+
if (bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet && bodyB.setIndex >= (int)B2SolverSetType.b2_firstSleepingSet)
291291
{
292292
b2WakeSolverSet(world, bodyB.setIndex);
293293
}
294294

295295
// Wake bodyA if bodyB is awake and bodyA is sleeping
296-
if (bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet && bodyA.setIndex >= (int)B2SolverSetType2.b2_firstSleepingSet)
296+
if (bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet && bodyA.setIndex >= (int)B2SolverSetType.b2_firstSleepingSet)
297297
{
298298
b2WakeSolverSet(world, bodyA.setIndex);
299299
}
@@ -302,8 +302,8 @@ internal static void b2LinkContact(B2World world, B2Contact contact)
302302
int islandIdB = bodyB.islandId;
303303

304304
// Static bodies have null island indices.
305-
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType2.b2_staticSet || islandIdA == B2_NULL_INDEX);
306-
B2_ASSERT(bodyB.setIndex != (int)B2SolverSetType2.b2_staticSet || islandIdB == B2_NULL_INDEX);
305+
B2_ASSERT(bodyA.setIndex != (int)B2SolverSetType.b2_staticSet || islandIdA == B2_NULL_INDEX);
306+
B2_ASSERT(bodyB.setIndex != (int)B2SolverSetType.b2_staticSet || islandIdB == B2_NULL_INDEX);
307307
B2_ASSERT(islandIdA != B2_NULL_INDEX || islandIdB != B2_NULL_INDEX);
308308

309309
// Merge islands. This will destroy one of the islands.
@@ -393,11 +393,11 @@ internal static void b2LinkJoint(B2World world, B2Joint joint)
393393

394394
B2_ASSERT(bodyA.type == B2BodyType.b2_dynamicBody || bodyB.type == B2BodyType.b2_dynamicBody);
395395

396-
if (bodyA.setIndex == (int)B2SolverSetType2.b2_awakeSet && bodyB.setIndex >= (int)B2SolverSetType2.b2_firstSleepingSet)
396+
if (bodyA.setIndex == (int)B2SolverSetType.b2_awakeSet && bodyB.setIndex >= (int)B2SolverSetType.b2_firstSleepingSet)
397397
{
398398
b2WakeSolverSet(world, bodyB.setIndex);
399399
}
400-
else if (bodyB.setIndex == (int)B2SolverSetType2.b2_awakeSet && bodyA.setIndex >= (int)B2SolverSetType2.b2_firstSleepingSet)
400+
else if (bodyB.setIndex == (int)B2SolverSetType.b2_awakeSet && bodyA.setIndex >= (int)B2SolverSetType.b2_firstSleepingSet)
401401
{
402402
b2WakeSolverSet(world, bodyA.setIndex);
403403
}
@@ -469,7 +469,7 @@ internal static void b2SplitIsland(B2World world, int baseId)
469469
B2Island baseIsland = b2Array_Get(ref world.islands, baseId);
470470
int setIndex = baseIsland.setIndex;
471471

472-
if (setIndex != (int)B2SolverSetType2.b2_awakeSet)
472+
if (setIndex != (int)B2SolverSetType.b2_awakeSet)
473473
{
474474
// can only split awake island
475475
return;
@@ -536,7 +536,7 @@ internal static void b2SplitIsland(B2World world, int baseId)
536536
// Grab the next body off the stack and add it to the island.
537537
int bodyId = stack[--stackCount];
538538
B2Body body = bodies[bodyId];
539-
B2_ASSERT(body.setIndex == (int)B2SolverSetType2.b2_awakeSet);
539+
B2_ASSERT(body.setIndex == (int)B2SolverSetType.b2_awakeSet);
540540
B2_ASSERT(body.islandId == islandId);
541541

542542
// Add body to island
@@ -586,7 +586,7 @@ internal static void b2SplitIsland(B2World world, int baseId)
586586
B2Body otherBody = bodies[otherBodyId];
587587

588588
// Maybe add other body to stack
589-
if (otherBody.islandId != islandId && otherBody.setIndex != (int)B2SolverSetType2.b2_staticSet)
589+
if (otherBody.islandId != islandId && otherBody.setIndex != (int)B2SolverSetType.b2_staticSet)
590590
{
591591
B2_ASSERT(stackCount < bodyCount);
592592
stack[stackCount++] = otherBodyId;
@@ -635,7 +635,7 @@ internal static void b2SplitIsland(B2World world, int baseId)
635635
}
636636

637637
// todo redundant with test below?
638-
if (joint.setIndex == (int)B2SolverSetType2.b2_disabledSet)
638+
if (joint.setIndex == (int)B2SolverSetType.b2_disabledSet)
639639
{
640640
continue;
641641
}
@@ -645,7 +645,7 @@ internal static void b2SplitIsland(B2World world, int baseId)
645645
B2Body otherBody = bodies[otherBodyId];
646646

647647
// Don't simulate joints connected to disabled bodies.
648-
if (otherBody.setIndex == (int)B2SolverSetType2.b2_disabledSet)
648+
if (otherBody.setIndex == (int)B2SolverSetType.b2_disabledSet)
649649
{
650650
continue;
651651
}
@@ -657,7 +657,7 @@ internal static void b2SplitIsland(B2World world, int baseId)
657657
}
658658

659659
// Maybe add other body to stack
660-
if (otherBody.islandId != islandId && otherBody.setIndex == (int)B2SolverSetType2.b2_awakeSet)
660+
if (otherBody.islandId != islandId && otherBody.setIndex == (int)B2SolverSetType.b2_awakeSet)
661661
{
662662
B2_ASSERT(stackCount < bodyCount);
663663
stack[stackCount++] = otherBodyId;

0 commit comments

Comments
 (0)