What does “step” mean in stepSimulation and what d

2019-04-29 23:44发布

What does the term "STEP" means in bullet physics?

What does the function stepSimulation() and its parameters mean?

I have read the documentation but i could not get hold of anything.

Any valid explanation would be of great help.

3条回答
看我几分像从前
2楼-- · 2019-04-30 00:39
btDynamicsWorld::stepSimulation(
   btScalar timeStep,
   int maxSubSteps=1,
   btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));

timeStep - time passed after last simulation.

Internally simulation is done for some internal constant steps. fixedTimeStep

fixedTimeStep ~~~ 0.01666666 = 1/60

if timeStep is 0.1 then it will include 6 (timeStep / fixedTimeStep) internal simulations.

To make glider movements BulletPhysics interpolate final step results according reminder after division (timeStep / fixedTimeStep)

查看更多
戒情不戒烟
3楼-- · 2019-04-30 00:40
  • timeStep - the amount of time in seconds to step the simulation by. Typically you're going to be passing it the time since you last called it.

  • maxSubSteps - the maximum number of steps that Bullet is allowed to take each time you call it.

  • fixedTimeStep - regulates resolution of the simulation. If your balls penetrates your walls instead of colliding with them try to decrease it.


Here i would like to address the issue in Proxy's answer about special meaning of value 1 for maxSubSteps. There is only one special value, that is 0 and you most likely don't want to use it because then simulation will go with non-constant time step. All other values are the same. Let's have a look at the actual code:

if (maxSubSteps)
{
    m_localTime += timeStep;
    ...
    if (m_localTime >= fixedTimeStep)
    {
        numSimulationSubSteps = int(m_localTime / fixedTimeStep);
        m_localTime -= numSimulationSubSteps * fixedTimeStep;
    }
}
...
if (numSimulationSubSteps)
{
    //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
    int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps) ? maxSubSteps : numSimulationSubSteps;
    ...
    for (int i = 0; i < clampedSimulationSteps; i++)
    {
        internalSingleStepSimulation(fixedTimeStep);
        synchronizeMotionStates();
    }
}

So, there is nothing special about maxSubSteps equal to 1. You should really abide this formula timeStep < maxSubSteps * fixedTimeStep if you don't want to lose time.

查看更多
趁早两清
4楼-- · 2019-04-30 00:45

I know I'm late, but I thought the accepted answer was only marginally better than the documentation's description.

timeStep: The amount of seconds, not milliseconds, passed since the last call to stepSimulation.

maxSubSteps: Should generally stay at one so Bullet interpolates current values on its own. A value of zero implies a variable tick rate, meaning Bullet advances the simulation exactly timeStep seconds instead of interpolating. This feature is buggy and not recommended. A value greater than one must always satisfy the equation timeStep < maxSubSteps * fixedTimeStep or you're losing time in the simulation.

fixedTimeStep: Inversely proportional to the simulation's resolution. Resolution increases as this value decreases. Keep in mind that a higher resolution means it takes more CPU.

查看更多
登录 后发表回答