diff --git a/src/contact.c b/src/contact.c index a4accdf..134e7b2 100644 --- a/src/contact.c +++ b/src/contact.c @@ -183,7 +183,7 @@ void b3CreateContact( b3World* world, b3Shape* shapeA, b3Shape* shapeB, int chil setIndex = b3_disabledSet; } - b3SolverSet* set = b3GetSolverSet( world, setIndex ); + b3SolverSet* set = b3GetFixedSolverSet( world, setIndex ); // Create contact key and contact int contactId = b3AllocId( &world->contactIdPool ); diff --git a/src/distance_joint.c b/src/distance_joint.c index 68c46b2..b89c670 100644 --- a/src/distance_joint.c +++ b/src/distance_joint.c @@ -256,8 +256,8 @@ void b3PrepareDistanceJoint( b3JointSim* base, b3StepContext* context ) B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/motor_joint.c b/src/motor_joint.c index 77e8567..6210d81 100644 --- a/src/motor_joint.c +++ b/src/motor_joint.c @@ -193,8 +193,8 @@ void b3PrepareMotorJoint( b3JointSim* base, b3StepContext* context ) B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/mover_joint.c b/src/mover_joint.c index 97a20c3..ac91319 100644 --- a/src/mover_joint.c +++ b/src/mover_joint.c @@ -65,8 +65,8 @@ void b3PrepareMoverJoint( b3JointSim* base, b3StepContext* context ) B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/parallel_joint.c b/src/parallel_joint.c index 82aaddc..e476db1 100644 --- a/src/parallel_joint.c +++ b/src/parallel_joint.c @@ -81,8 +81,8 @@ void b3PrepareParallelJoint( b3JointSim* base, b3StepContext* context ) b3Body* bodyB = b3Array_Get( world->bodies, base->bodyIdB ); B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/physics_world.h b/src/physics_world.h index 2b3941c..2586922 100644 --- a/src/physics_world.h +++ b/src/physics_world.h @@ -312,6 +312,12 @@ static inline b3SolverSet* b3GetSolverSet( b3World* world, int setIndex ) return b3Array_Get( world->sleepingSets, setIndex - b3_firstSleepingSet ); } +static inline b3SolverSet* b3GetFixedSolverSet( b3World* world, int setIndex ) +{ + B3_ASSERT( 0 <= setIndex && setIndex < b3_firstSleepingSet ); + return world->fixedSets + setIndex; +} + static inline int b3GetSolverSetCount( const b3World* world ) { return b3_firstSleepingSet + world->sleepingSets.count; diff --git a/src/pogo_joint.c b/src/pogo_joint.c index 0a56c74..cd51be6 100644 --- a/src/pogo_joint.c +++ b/src/pogo_joint.c @@ -184,8 +184,8 @@ void b3PreparePogoJoint( b3JointSim* base, b3StepContext* context ) B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/prismatic_joint.c b/src/prismatic_joint.c index 4c5c3a5..3950e5f 100644 --- a/src/prismatic_joint.c +++ b/src/prismatic_joint.c @@ -308,8 +308,8 @@ void b3PreparePrismaticJoint( b3JointSim* base, b3StepContext* context ) b3Body* bodyB = b3Array_Get( world->bodies, base->bodyIdB ); B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/revolute_joint.c b/src/revolute_joint.c index d177a4f..899d2d8 100644 --- a/src/revolute_joint.c +++ b/src/revolute_joint.c @@ -267,8 +267,8 @@ void b3PrepareRevoluteJoint( b3JointSim* base, b3StepContext* context ) b3Body* bodyB = b3Array_Get( world->bodies, base->bodyIdB ); B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/spherical_joint.c b/src/spherical_joint.c index 43a2abc..2058858 100644 --- a/src/spherical_joint.c +++ b/src/spherical_joint.c @@ -301,8 +301,8 @@ void b3PrepareSphericalJoint( b3JointSim* base, b3StepContext* context ) b3Body* bodyB = b3Array_Get( world->bodies, base->bodyIdB ); B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/weld_joint.c b/src/weld_joint.c index fd8c94a..21d7d35 100644 --- a/src/weld_joint.c +++ b/src/weld_joint.c @@ -92,8 +92,8 @@ void b3PrepareWeldJoint( b3JointSim* base, b3StepContext* context ) b3Body* bodyB = b3Array_Get( world->bodies, base->bodyIdB ); B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex; diff --git a/src/wheel_joint.c b/src/wheel_joint.c index 8480a0b..6201cff 100644 --- a/src/wheel_joint.c +++ b/src/wheel_joint.c @@ -416,8 +416,8 @@ void b3PrepareWheelJoint( b3JointSim* base, b3StepContext* context ) b3Body* bodyB = b3Array_Get( world->bodies, idB ); B3_ASSERT( bodyA->setIndex == b3_awakeSet || bodyB->setIndex == b3_awakeSet ); - b3SolverSet* setA = b3GetSolverSet( world, bodyA->setIndex ); - b3SolverSet* setB = b3GetSolverSet( world, bodyB->setIndex ); + b3SolverSet* setA = b3GetFixedSolverSet( world, bodyA->setIndex ); + b3SolverSet* setB = b3GetFixedSolverSet( world, bodyB->setIndex ); int localIndexA = bodyA->localIndex; int localIndexB = bodyB->localIndex;