From 3c57b9d94594ec1ab0b22bc989438ae819458f3f Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 14 Nov 2016 18:16:30 +0200 Subject: [PATCH] Fixed particle velocity being set to { NaN, NaN } if drag is applied when velocity is almost zero --- Subsurface/Source/Particles/Particle.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Subsurface/Source/Particles/Particle.cs b/Subsurface/Source/Particles/Particle.cs index d2c65e0f8..9ac4d7b0c 100644 --- a/Subsurface/Source/Particles/Particle.cs +++ b/Subsurface/Source/Particles/Particle.cs @@ -226,9 +226,9 @@ namespace Barotrauma.Particles private void ApplyDrag(float dragCoefficient, float deltaTime) { - if (velocity == Vector2.Zero) return; - + if (Math.Abs(velocity.X) < 0.0001f && Math.Abs(velocity.Y) < 0.0001f) return; float speed = velocity.Length(); + velocity -= (velocity / speed) * Math.Min(speed * speed * prefab.WaterDrag * deltaTime, 1.0f); }