Upper limit to water drag force, fixed highlighted items "flickering"

This commit is contained in:
Regalis
2016-10-09 20:45:28 +03:00
parent d4e9116b0f
commit 74a9453676
2 changed files with 4 additions and 3 deletions

View File

@@ -462,14 +462,14 @@ namespace Barotrauma
Vector2 normal = new Vector2(-line.Y, line.X);
normal = Vector2.Normalize(-normal);
float dragDot = Vector2.Dot(normal, velDir);
float dragDot = Math.Abs(Vector2.Dot(normal, velDir));
Vector2 dragForce = Vector2.Zero;
if (dragDot > 0)
{
float vel = LinearVelocity.Length()*2.0f;
float drag = dragDot * vel * vel
* ConvertUnits.ToSimUnits(sprite.size.Y);
dragForce = drag * -velDir;
dragForce = Math.Min(drag, Mass*1000.0f) * -velDir;
//if (dragForce.Length() > 100.0f) { }
}

View File

@@ -703,6 +703,8 @@ namespace Barotrauma
inWater = IsInWater();
if (inWater) ApplyStatusEffects(ActionType.InWater, deltaTime);
isHighlighted = false;
if (body == null || !body.Enabled) return;
if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f)
@@ -881,7 +883,6 @@ namespace Barotrauma
if (!editing || (body != null && !body.Enabled))
{
isHighlighted = false;
return;
}