BulletSim: fix small bug where everything looked like it was colliding

before the first simulator step.
cpu-performance
Robert Adams 2013-07-17 10:19:44 -07:00
parent 894554faf6
commit 2c8bf4aaa6
2 changed files with 10 additions and 6 deletions

View File

@ -103,9 +103,10 @@ public abstract class BSPhysObject : PhysicsActor
CollisionsLastTickStep = -1;
SubscribedEventsMs = 0;
CollidingStep = 0;
CollidingGroundStep = 0;
CollisionAccumulation = 0;
// Crazy values that will never be true
CollidingStep = BSScene.NotASimulationStep;
CollidingGroundStep = BSScene.NotASimulationStep;
CollisionAccumulation = BSScene.NotASimulationStep;
ColliderIsMoving = false;
CollisionScore = 0;
@ -349,7 +350,7 @@ public abstract class BSPhysObject : PhysicsActor
if (value)
CollidingStep = PhysScene.SimulationStep;
else
CollidingStep = 0;
CollidingStep = BSScene.NotASimulationStep;
}
}
public override bool CollidingGround {
@ -359,7 +360,7 @@ public abstract class BSPhysObject : PhysicsActor
if (value)
CollidingGroundStep = PhysScene.SimulationStep;
else
CollidingGroundStep = 0;
CollidingGroundStep = BSScene.NotASimulationStep;
}
}
public override bool CollidingObj {
@ -368,7 +369,7 @@ public abstract class BSPhysObject : PhysicsActor
if (value)
CollidingObjectStep = PhysScene.SimulationStep;
else
CollidingObjectStep = 0;
CollidingObjectStep = BSScene.NotASimulationStep;
}
}

View File

@ -97,6 +97,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
internal long m_simulationStep = 0; // The current simulation step.
public long SimulationStep { get { return m_simulationStep; } }
// A number to use for SimulationStep that is probably not any step value
// Used by the collision code (which remembers the step when a collision happens) to remember not any simulation step.
public static long NotASimulationStep = -1234;
internal float LastTimeStep { get; private set; } // The simulation time from the last invocation of Simulate()