Fixed particle velocity being set to { NaN, NaN } if drag is applied when velocity is almost zero

This commit is contained in:
Regalis
2016-11-14 18:16:30 +02:00
parent 335bf00890
commit 3c57b9d945
+2 -2
View File
@@ -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);
}