Instability with high framerate

Post Reply
Petwoip
Posts: 5
Joined: Sun Jan 15, 2012 10:53 pm

Instability with high framerate

Post by Petwoip »

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:

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;
}
Then I found out that bullet gives a bit more control in the stepSimulation function and I changed my code to:

Code: Select all

m_physicsWorld->stepSimulation(frameTime, 100); // 100 is just some arbitrarily high number of substeps
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?
Post Reply