Page 1 of 1

Why bullet proposes value to clamp number of substeps?

Posted: Fri Nov 02, 2018 9:13 am
by Yola
Why bullet needs maxSubSteps at all? Why to clamp value at all? In the code i saw the following comment:

Code: Select all

    //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
    int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps) ? maxSubSteps : numSimulationSubSteps;
What does it mean?
code wrote: simulation grinding spiralling down

Re: Why bullet proposes value to clamp number of substeps?

Posted: Tue Nov 06, 2018 4:57 am
by Erwin Coumans
Clamping is important in real-time simulations, otherwise you get a feedback loop of slower and slower (grinding to a halt) if the time it takes to simulate is slower then the real-time clock.

Code: Select all

dt = clock.deltaTime();
stepSimulation(dt);//if this takes longer than dt, then the next iteration, the dt will be larger, and stepSimulation also takes longer etc etc.