Question

I use Bullet for physics simulation and don't care about real-time simulation - it's ok if one minute of model time lasts two hours in real time. I am trying to call a callback every fixed amount of time in model time, but realized that I don't understand how StepSimulation works.

The documentation of StepSimulation() isn't that clear. I would strongly appreciate if someone explained what its parameters are for.

  • timeStep is simply the amount of time to step the simulation by. Typically you're going to be passing it the time since you last called it.

Why is it so? Why does everyone use the time passed since last simulation for this parameter? What will happen if we make this parameter fixed - say 0.1?

  • The third parameter is the size of that internal step. The second parameter is the maximum number of steps that Bullet is allowed to take each time you call it. It's important that timeStep < maxSubSteps * fixedTimeStep, otherwise you are losing time.

What exactly is internal step? Why is its size inversely proportional to resolution? Is it basically inverse frequency?

P.S. I somewhat duplicate the question which already exists, but the answer doesn't clarify what I would like to know.

Was it helpful?

Solution

Why is it so? Why does everyone use the time passed since last simulation for this parameter? What will happen if we make this parameter fixed - say 0.1?

It is so because the physics needs to know how much time has passed or it will run too fast or slow and will appear wrong to the user.

You can absolutely fix the parameter for your application.

For example

stepSimulation(btScalar(1.)/btScalar(60.), btScalar(1.)/btScalar(60.));

Will step your physics world on by 1/60th of a second. In a game this would result in it running faster/slower depending on how far out the actual frame rate is from the 1/60th of a second we are passing.

What exactly is internal step? Why is its size inversely proportional to resolution? Is it basically inverse frequency?

It is the duration that bullet will simulate at a time. For example, if you put 1/60 and 1/6 of a second has passed since the last step, then bullet will do 10 internal steps and not one large 1/6 step. This is so that it will produce the same results. A varying timestep will not.

This is a great article on why you need a fixed physics timestep and what happens when you don't: http://gafferongames.com/game-physics/fix-your-timestep/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top