Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  gravity does not apply when I manually set the fixed delta time
#4
(10-01-2022, 11:35 AM)lufydad Wrote: Thank you a lot it seems to work, when I reduce the sleep threshold  Sonrisa
In my application the fixed delta time is entered by user, which sleep threshold should I use to be sure to not have this problem anymore and avoid drifting and jittering ? dt/10 is enough ?


Allowing your user to set an arbitrary fixed delta time is a recipe for terrible performance, but assuming you're not concerned by this: You could use the smallest value that works with the smallest delta time you allow.

Or instead of using a very small threshold (which may not be enough for very small timesteps), you can calculate the value you need for a given timestep.
Kinetic energy is defined as 1/2 * sqr(velocity) * mass. In Obi, the threshold is mass-normalized, so not multiplied by mass.

Velocity is defined as change in position over time. In Unity, this "time" is the timestep (aka fixed delta time) value. So:

Code:
velocity = (position at the end of the timestep - position at the start of the timestep) / timestep.

Hence, kinetic energy is:

Code:
1/2 * sqr((end position - start position) / timestep).

This is the value compared to your sleep threshold to determine if a particle can move or not.
To make the threshold independent of timestep, you can do:

Code:
timestepIndependentThreshold = sqrt(threshold * 2) * timestep;

And then feed this value to Obi instead of a fixed threshold.
Reply


Messages In This Thread
RE: gravity does not apply when I manually set the fixed delta time - by josemendez - 10-01-2022, 11:48 AM