Instability with high framerate
Posted: Thu Jan 31, 2013 4:07 am
I'm experiencing some weird instability with bullet when my framerate is high.
In the beginning my code looked like this and it worked great for all framerates because it would only do one simulation step every 1/60th of a second. In the event that the framerate was really high, the timeAccumulator would add up over several frames until 1/60th of a second was reached:
Then I found out that bullet gives a bit more control in the stepSimulation function and I changed my code to:
Overall, the new code works great for anything 60fps and less (using vsync). However, my application runs at about +1000fps and I'm noticing some problems with the physics. Namely, rayTest operations seem to fail about half the time and forces don't always register for objects. Otherwise, the collisions look fairly accurate. Is my framerate causing bullet interpolators to become unstable and thus give bad results?
In the beginning my code looked like this and it worked great for all framerates because it would only do one simulation step every 1/60th of a second. In the event that the framerate was really high, the timeAccumulator would add up over several frames until 1/60th of a second was reached:
Code: Select all
m_timeStep = 1.0f/60.0f
m_timeAccumulator += frameTime;
while(m_timeAccumulator >= m_timeStep)
{
m_physicsWorld->stepSimulation(m_timeStep);
m_timeAccumulator -= m_timeStep;
}
Code: Select all
m_physicsWorld->stepSimulation(frameTime, 100); // 100 is just some arbitrarily high number of substeps