Game Development Reference
Stepping the simulation
So, now we're rendering a graphical box in the same place as our physical box, but
we still don't see it moving. This is because the box isn't actually moving. Why? Be-
cause Bullet has not been told to step the simulation, yet!
In order to do this, we simply call stepSimulation() on our btDynamicsWorld
object, providing the number of seconds that have elapsed since the last iteration.
The challenge here is counting the amount of time that has passed, since the last time
we called stepSimulation() .
Bullet comes with a built-in btClock object, but if you have your own clock tool in
mind, which you trust to be more precise, then there's nothing stopping you from us-
ing that for a counter instead. A good place to handle this logic is in the application
layer class with the following member variable:
The clock can be used to calculate the time since the last step and updating the ap-
float dt = m_clock.getTimeMilliseconds();
UpdateScene(dt / 1000.0f);
When we launch our application again, we should observe our box falling under the
effects of gravity as in the following screenshot: