Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to know when all the particles are sleeping so I can de-activate the ObiEmitter
#2
(15-04-2020, 12:50 AM)facaelectrica Wrote: Hi,

I'm using the ObiFluid to simulate liquid pooling and I would like to know when all the particles have stopped moving so I can 'freeze' the simulation on the ObjEmitter since it won't be interacted with anymore once all particles have stopped.

I noticed that if I manually disable the Obi Emitter modifier I see the framerate recover but otherwise, even if the particles aren't moving anymore, it seems to still be calculating.

Is there a way to check if all particles of a specific Obi Emitter are sleeping and disable it?

Hi!

The component that actually performs the simulation is the solver, so that's what you want to deactivate, not the emitter. See:
http://obi.virtualmethodstudio.com/tutor...olver.html

Regarding the sleep threshold, quote from the docs:

Quote:Sleep threshold: Any particle with a kinetic energy below this value will be freezed in place. This is useful when you donĀ“t want minuscule variations in velocity or force to perturb an actor, making it look like its jittering or moving very slowly.

It is important to note that sleeping particles aren't skipped when asleep, it is just that their velocity is not used to update their position. This way, tiny velocities won't move the particle around. This is similar to how articulated bodies in physx can't have their individual links sleeping, only the entire articulation can go to sleep once all links have their kinetic energy below a threshold.

Kinetic energy is just 1/2*mass*sqr(velocity). Because we want the sleep threshold to work the same regardless of particle mass, internally we ignore mass in the formula, leaving: 1/2*sqr(velocity).

So simply iterate over all particles, checking if half of the squared magnitude of their velocity is below the sleep threshold. However, determining when to re-enable the solver isn't trivial at all: the simulation is no longer being updated, so you can't rely on particle velocities or the simulation internals for this. Depending on your use case this might not be an issue (maybe you don't ever need to re-enable the solver after all particles stop moving).
Reply


Messages In This Thread
RE: How to know when all the particles are sleeping so I can de-activate the ObiEmitter - by josemendez - 15-04-2020, 10:08 AM