Obi Official Forum
Is there a way to check that simulation done and all particles is sleeping? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Is there a way to check that simulation done and all particles is sleeping? (/thread-662.html)



Is there a way to check that simulation done and all particles is sleeping? - mmortall - 22-08-2018

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?


RE: Is there a way to check that simulation done and all particles is sleeping? - josemendez - 22-08-2018

(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/tutorials/scriptingparticles.html for more info on how to use low level particle getter/setters.


RE: Is there a way to check that simulation done and all particles is sleeping? - mmortall - 22-08-2018

(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/tutorials/scriptingparticles.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.


RE: Is there a way to check that simulation done and all particles is sleeping? - mmortall - 07-05-2019

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


RE: Is there a way to check that simulation done and all particles is sleeping? - josemendez - 07-05-2019

(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/tutorials/scriptingparticles.html


RE: Is there a way to check that simulation done and all particles is sleeping? - mmortall - 08-05-2019

(07-05-2019, 08:34 PM)josemendez Wrote: Hi,

See the updated docs:
http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html

Thanks. Will try it