Posts: 50
Threads: 14
Joined: Nov 2021
Reputation:
0
10-01-2022, 11:17 AM
(This post was last modified: 10-01-2022, 11:21 AM by lufydad.)
Hello,
When I set the fixed delta time from script to 1/60 in an empty scene with just a rope, the rope just stay still, the gravity does not seem to apply on it. If I change the fixed delta time to another value the rope falls down normally.
I use Obi 6.2, Unity 2021.2.4f, and DX11.
Is there something that I can do to fixed this ?
Posts: 5,974
Threads: 22
Joined: Jun 2017
Reputation:
383
Obi Owner:
10-01-2022, 11:30 AM
(This post was last modified: 10-01-2022, 11:32 AM by josemendez.)
(10-01-2022, 11:17 AM)lufydad Wrote: Hello,
When I set the fixed delta time from script to 1/60 in an empty scene with just a rope, the rope just stay still, the gravity does not seem to apply on it. If I change the fixed delta time to another value the rope falls down normally.
I use Obi 6.2, Unity 2021.2.4f, and DX11.
Is there something that I can do to fixed this ? Hi!
Just set the solver's sleep threshold accordingly. This is the minimum kinetic energy above which particles are allowed to move. If you reduce the timestep, the kinetic energy during a single timestep will also be reduced, preventing any particle whose energy is below the threshold to move. See:
http://obi.virtualmethodstudio.com/manua...olver.html
You can set it to zero if you want particles to move regardless of how much energy they have. Note this may result in positional drifting/jittering.
Posts: 50
Threads: 14
Joined: Nov 2021
Reputation:
0
(10-01-2022, 11:30 AM)josemendez Wrote: Hi!
Just set the solver's sleep threshold accordingly. This is the minimum kinetic energy above which particles are allowed to move. If you reduce the timestep, the kinetic energy during a single timestep will also be reduced, preventing any particle whose energy is below the threshold to move. See:
http://obi.virtualmethodstudio.com/manua...olver.html
You can set it to zero if you want particles to move regardless of how much energy they have. Note this may result in positional drifting/jittering.
Thank you a lot it seems to work, when I reduce the sleep thresholdÂ
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 ?
Posts: 5,974
Threads: 22
Joined: Jun 2017
Reputation:
383
Obi Owner:
10-01-2022, 11:48 AM
(This post was last modified: 10-01-2022, 11:53 AM by josemendez.)
(10-01-2022, 11:35 AM)lufydad Wrote: Thank you a lot it seems to work, when I reduce the sleep thresholdÂ
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.
Posts: 50
Threads: 14
Joined: Nov 2021
Reputation:
0
(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 ?
Posts: 5,974
Threads: 22
Joined: Jun 2017
Reputation:
383
Obi Owner:
10-01-2022, 02:44 PM
(This post was last modified: 10-01-2022, 02:45 PM by josemendez.)
(10-01-2022, 02:43 PM)lufydad Wrote: 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 ?
Hi!
"Theshold" is the (time-dependent) input threshold you want to use, this is a value you set. The equation outputs a time-independent threshold, which is the one you feed to the solver's sleepThreshold.
So the equation sits in between your hand-picked threshold value, and the one fed to Obi.
Posts: 50
Threads: 14
Joined: Nov 2021
Reputation:
0
(10-01-2022, 02:44 PM)josemendez Wrote: Hi!
"Theshold" is the (time-dependent) input threshold you want to use, this is a value you set. The equation outputs a time-independent threshold, which is the one you feed to the solver's sleepThreshold.
So the equation sits in between your hand-picked threshold value, and the one fed to Obi.
Ok, then suppose I input 0.001 for the sleepThreshold at the beginning of the simulation and the user input 1/60 for the fixedDeltaFrame, then using your equation :
Code: timestepIndependentThreshold = sqrt(0.001 * 2) * 1/60 = 3.33*1e-5
I should put the sleepThreshold to this value, is this correct ?
Posts: 5,974
Threads: 22
Joined: Jun 2017
Reputation:
383
Obi Owner:
(10-01-2022, 02:56 PM)lufydad Wrote: Ok, then suppose I input 0.001 for the sleepThreshold at the beginning of the simulation and the user input 1/60 for the fixedDeltaFrame, then using your equation :
Code: timestepIndependentThreshold = sqrt(0.001 * 2) * 1/60 = 3.33*1e-5
I should put the sleepThreshold to this value, is this correct ?
Yes, that should work.
Posts: 50
Threads: 14
Joined: Nov 2021
Reputation:
0
(10-01-2022, 02:59 PM)josemendez Wrote: Yes, that should work.
Great !! Once again, thanks a lot
Posts: 5,974
Threads: 22
Joined: Jun 2017
Reputation:
383
Obi Owner:
(10-01-2022, 03:06 PM)lufydad Wrote: Great !! Once again, thanks a lot ![Gran sonrisa Gran sonrisa](https://obi.virtualmethodstudio.com/forum/images/smilies/biggrin.png) You're welcome!
|