useInternalTimeStepping bug?
Posted: Thu Aug 05, 2010 11:19 am
Is it possible that useInternalTimeStepping is bugged? I've gone up and down my code and can't figure out what I might be doing to break it. It seems that timeStepDuration is inversely proportional to the effective timeScale. Setting timeStepDuration to 1 results in a super-speed simulation, and setting it low makes the simulation go very slowly. Shouldn't the actual speed of the objects remain the same regardless of the timeStepDuration?
This is my main physics loop. I can't think of any other place that should affect the speed of the simulation.
This is my main physics loop. I can't think of any other place that should affect the speed of the simulation.
Code: Select all
... extracted from setup ...
m_PhysicsSpace.simulationSettings.timeStep.timeStepDuration = 1 / Constants.PHYSICS_FRAMES_PER_SECOND;
m_PhysicsSpace.simulationSettings.timeStep.timeScale = 1;
m_PhysicsSpace.simulationSettings.timeStep.useInternalTimeStepping = true;
Code: Select all
void physicsLoop( )
{
Stopwatch totalTime = new Stopwatch();
Stopwatch physicsThinkTime = new Stopwatch();
totalTime.Start();
// Use lastFrameTime instead of turning on/off a stopwatch so that we
// don't lose any milliseconds or portions thereof.
float lastFrameTime = 0;
Debug.Assert(Stopwatch.IsHighResolution);
while ( true )
{
#region Shutdown
if (ShutdownRequested)
break;
#endregion
#region Pausing
if (m_PhysicsPaused)
{
Thread.Sleep(500);
lastFrameTime = totalTime.ElapsedMilliseconds;
continue;
}
#endregion
physicsThinkTime.Reset();
physicsThinkTime.Start();
{
updatePhysicsObjectList();
beforePhysics();
float newtime = totalTime.ElapsedMilliseconds;
m_PhysicsSpace.update( newtime - lastFrameTime );
lastFrameTime = newtime;
}
physicsThinkTime.Stop();
reportPhysicsStatistics(physicsThinkTime.ElapsedMilliseconds);
}
}