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