What does “step” mean in stepSimulation and what do its parameters mean in Bullet Physics?

旧城冷巷雨未停 提交于 2019-12-22 07:20:11

问题


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.


回答1:


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)




回答2:


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.




回答3:


  • 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.



来源:https://stackoverflow.com/questions/12778229/what-does-step-mean-in-stepsimulation-and-what-do-its-parameters-mean-in-bulle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!