Physics simulation rate

How is physics simulation step rate handled under the hood? Is it a fixed rate or tied to one of the configs such as update_rate? Is it impacted by variable_dt?

Answering my own question… it looks like it is based on its parent collection time step.

http://www.defold.com/ref/collection-proxy/#set_time_step:factor-mode

2 Likes

Exactly the same as the dt the scripts receive in their updates. They are controlled with variable_dt, display/update_frequency and the parent collection time step. In the future we might do render decoupling, but it’s less likely that the rates between scripts and physics will behave differently.

3 Likes

Thank you for explaining.

So users shouldn’t be worried about unfixed timesteps with box2d simulations at all?

Has anything changed with vsync reliance?

3 Likes

Yes, it’s always preferred to do fixed time step and have variable_dt unchecked. However, the simulation is pretty stable as long as there are no major hitches. Since it’s very cheap in Defold to create/destroy things, the hitches usually come from scripts (mostly GC), or in some cases from a sudden explosion of particles and effects which could stall both CPU and GPU.
Regarding vsync, we always rely on it for timing, which we of course need to fix at some point. Something like software throttling of the update.

4 Likes