public void Update(float deltaTime) { _deltaTime2 = deltaTime * deltaTime; ApplyViscosity(deltaTime); //Update velocity UpdateParticleVelocity(deltaTime); Particles.Rehash(); if (_elasticityEnabled) { CalculateElasticity(deltaTime); } if (_plasticityEnabled) { CalculatePlasticity(deltaTime); } DoubleDensityRelaxation(); foreach (Particle particle in Particles) { particle.Velocity.Set((particle.Position.X - particle.PreviousPosition.X) / deltaTime, (particle.Position.Y - particle.PreviousPosition.Y) / deltaTime); ApplyGravity(particle); WallCollision(particle); CapVelocity(particle.Velocity); } }
public void Update(float deltaTime) { if (deltaTime == 0) { return; } _deltaTime2 = deltaTime * deltaTime; ApplyViscosity(deltaTime); //Update velocity UpdateParticleVelocity(deltaTime); Particles.Rehash(); if (_elasticityEnabled) { CalculateElasticity(deltaTime); } if (_plasticityEnabled) { CalculatePlasticity(deltaTime); } DoubleDensityRelaxation(); for (int i = 0; i < Particles.Count; i++) { Particle particle = Particles[i]; particle.Velocity = new Vector2((particle.Position.X - particle.PreviousPosition.X) / deltaTime, (particle.Position.Y - particle.PreviousPosition.Y) / deltaTime); ApplyGravity(particle); WallCollision(particle); CapVelocity(particle.Velocity); } }