Obi Official Forum
How make slow disappearing puddle? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: How make slow disappearing puddle? (/thread-974.html)



How make slow disappearing puddle? - Andrew - 13-03-2019

Can i make slow disappearing puddle, by decrease radius of each particle witch collide with the floor? I try to change the size of particle by Obi Particle Renderer, but it scale all rendered particles. And new flow of water affect old one. Or exists some method to split particles and change scale of each groups by Obi Particle Renderer.


RE: How make slow disappearing puddle? - josemendez - 13-03-2019

(13-03-2019, 08:20 AM)Andrew Wrote: Can i make slow disappearing puddle, by decrease radius of each particle witch collide with the floor? I try to change the size of particle by Obi Particle Renderer, but it scale all rendered particles. And new flow of water affect old one. Or exists some method to split particles and change scale of each groups by Obi Particle Renderer.

Hi,

You cannot change the size of fluid particles at runtime, because each one of them represents a fixed volume of fluid. Removing particles one by one is the only method of making fluid disappear.


RE: How make slow disappearing puddle? - Andrew - 13-03-2019

(13-03-2019, 08:38 AM)josemendez Wrote: Hi,

You cannot change the size of fluid particles at runtime, because each one of them represents a fixed volume of fluid. Removing particles one by one is the only method of making fluid disappear.

Thanks! Can you help me with it? I know how delete particles on collision, but i'm not sure how to store all particle after collision and remove it while after some time.
   
Code:
   private HashSet<int> currentParticles = new HashSet<int>();
   void Solver_OnCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
   {
       if (e.contacts.Count > 0)
       {
           currentParticles = new HashSet<int>();
           for (int i = 0; i < e.contacts.Count; ++i)
           {
               if (e.contacts.Data[i].distance < 0.001f)
               {

                   Component collider;
                   if (ObiCollider.idToCollider.TryGetValue(e.contacts.Data[i].other, out collider))
                   {
                       if (collider == _targetCollider)
                       {
                           currentParticles.Add(e.contacts.Data[i].particle);
                           ObiSolver.ParticleInActor pa = _solver.particleToActor[e.contacts[i].particle];
                           ObiEmitter emitter = pa.actor as ObiEmitter;

                           if (emitter != null && emitter.fluidPhase != 4)
                               emitter.life[pa.indexInActor] = 0;
                       }
                   }
               }
           }

           _particles.ExceptWith(currentParticles);
           _counter += _particles.Count;
           _particles = currentParticles;
       }
   }
 Is this code need some improvement to accurate calculate all particles?