Obi Official Forum

Full Version: Is there a way to check that simulation done and all particles is sleeping?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need somehow to know that all particles are in sleep state. Because I need to stop simulation then, save simulation mesh etc. 
For now I use just a timer, but I want to use some smart way to check simulation done. So basically I need to know a percent of perticles are in sleep state and if like 99% in sleep state then considering simulation done.

It there a way to do what I wan currently?
(22-08-2018, 03:48 PM)mmortall Wrote: [ -> ]I need somehow to know that all particles are in sleep state. Because I need to stop simulation then, save simulation mesh etc. 
For now I use just a timer, but I want to use some smart way to check simulation done. So basically I need to know a percent of perticles are in sleep state and if like 99% in sleep state then considering simulation done.

It there a way to do what I wan currently?

The sleep threshold is expressed in Joules/Kg. So simply check if the kinetic energy of the particles is below the sleep threshold. Pseudocode:

Code:
Oni.GetParticleVelocities(solver,velocities,numParticles,startingParticle);
for (int i = 0; i < velocities.Length;++i)
{
    if (velocities[i].sqrMagnitude * 0.5f <= solver.parameters.sleepThreshold)
     // this one is sleeping.
}

See the last bit of: http://obi.virtualmethodstudio.com/tutor...icles.html for more info on how to use low level particle getter/setters.
(22-08-2018, 04:03 PM)josemendez Wrote: [ -> ]The sleep threshold is expressed in Joules/Kg. So simply check if the kinetic energy of the particles is below the sleep threshold. Pseudocode:

Code:
Oni.GetParticleVelocities(solver,velocities,numParticles,startingParticle);
for (int i = 0; i < velocities.Length;++i)
{
    if (velocities[i].sqrMagnitude * 0.5f <= solver.parameters.sleepThreshold)
     // this one is sleeping.
}

See the last bit of: http://obi.virtualmethodstudio.com/tutor...icles.html for more info on how to use low level particle getter/setters.

Thanks a lot for help. This is exactly what I am looking for.
Hello. 

After updating to the new Obi version 4.0.2 and there is no more GetParticleVelocities method. 
So I am not able to check the simulation done condition. 
How can I do it now in a new version? Thanks
(07-05-2019, 06:41 PM)mmortall Wrote: [ -> ]Hello. 

After updating to the new Obi version 4.0.2 and there is no more GetParticleVelocities method. 
So I am not able to check the simulation done condition. 
How can I do it now in a new version? Thanks

Hi,

See the updated docs:
http://obi.virtualmethodstudio.com/tutor...icles.html
(07-05-2019, 08:34 PM)josemendez Wrote: [ -> ]Hi,

See the updated docs:
http://obi.virtualmethodstudio.com/tutor...icles.html

Thanks. Will try it