I have integrated Bullet physics to my engine and I am having trouble with the timestep. I have read the "Fix your timestep" and other articles regarding this issue, but none of them help me with my design. This is my update function:
int SFMLWindow::run() {
bool bRunning = true;
sf::Clock clock;
sf::Time oldTime = clock.getElapsedTime();
sf::Time deltaTime;
while(bRunning) {
sf::Time currentTime = clock.getElapsedTime();
deltaTime = currentTime - oldTime;
currentTime = oldTime;
mRenderWindow.clear();
mRenderWindow.pushGLStates();
mCurrentState->update(deltaTime.asSeconds());
mRenderWindow.popGLStates();
mRenderWindow.display();
}
return 0;
}
The state holds all the systems and passed the "deltaTime.asSeconds()" parameter to the update function of these systems. And here is the bullet physics update function:
void BulletPhysicsSystem::update(double dt) {
mWorld->stepSimulation(dt,10.0);
}
The problem is, the sphere I have in my scene goes with a speed of light to the ground. What should I add or do?