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
#5
(10-01-2022, 11:48 AM)josemendez Wrote: 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.

Thank you for taking the time to explain.
If I may ask one last question, I don't understand the last equation of your post. Is "threshold" in the equation the member sleepThreshold of obi solver ?
Reply


Messages In This Thread
RE: gravity does not apply when I manually set the fixed delta time - by lufydad - 10-01-2022, 02:43 PM