Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How make slow disappearing puddle?
#3
(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?
Reply


Messages In This Thread
How make slow disappearing puddle? - by Andrew - 13-03-2019, 08:20 AM
RE: How make slow disappearing puddle? - by Andrew - 13-03-2019, 09:16 AM