Unstable 0.14.5.0

This commit is contained in:
Markus Isberg
2021-06-14 17:53:42 +03:00
parent 1f3e588fcd
commit 23a7c37eee
25 changed files with 254 additions and 259 deletions
@@ -421,21 +421,32 @@ namespace Barotrauma.Particles
private void ApplyDrag(float dragCoefficient, float deltaTime)
{
Vector2 relativeVel = velocity;
if (currentHull?.Submarine != null)
{
relativeVel = velocity - ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
}
float speed = velocity.Length();
velocity /= speed;
float speed = relativeVel.Length();
relativeVel /= speed;
float drag = speed * speed * dragCoefficient * 0.01f * deltaTime;
if (drag > speed)
{
velocity = Vector2.Zero;
relativeVel = Vector2.Zero;
}
else
{
speed -= drag;
velocity *= speed;
relativeVel *= speed;
}
velocity = relativeVel;
if (currentHull?.Submarine != null)
{
velocity += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
}
}