Anim tweaking, simplified (+ non-broken) water drag logic

This commit is contained in:
Regalis
2016-12-09 15:02:48 +02:00
parent f04ebf1503
commit 3eec463f5e
2 changed files with 16 additions and 24 deletions

View File

@@ -260,9 +260,9 @@ namespace Barotrauma
float slowdownAmount = 0.0f;
if (currentHull != null)
{
//full slowdown (1.0f) when water is up to the torso
//full slowdown (1.5f) when water is up to the torso
surfaceY = ConvertUnits.ToSimUnits(currentHull.Surface);
slowdownAmount = MathHelper.Clamp((surfaceY - colliderPos.Y) / torsoPosition, 0.0f, 1.0f);
slowdownAmount = MathHelper.Clamp((surfaceY - colliderPos.Y) / torsoPosition, 0.0f, 1.0f) * 1.5f;
}
float maxSpeed = Math.Max(TargetMovement.Length() - slowdownAmount, 1.0f);
@@ -272,7 +272,7 @@ namespace Barotrauma
float walkPosX = (float)Math.Cos(walkPos);
float walkPosY = (float)Math.Sin(walkPos);
float runningModifier = (float)Math.Max(Math.Min(Math.Abs(TargetMovement.X), 3.0f) / 1.5f, 1.0);
Vector2 stepSize = new Vector2(
this.stepSize.X * walkPosX * runningModifier,
this.stepSize.Y * walkPosY * runningModifier * runningModifier);
@@ -751,9 +751,9 @@ namespace Barotrauma
ladderSimPos += character.SelectedConstruction.Submarine.SimPosition - currentHull.Submarine.SimPosition;
}
MoveLimb(head, new Vector2(ladderSimPos.X - 0.27f * Dir, Collider.SimPosition.Y + 0.7f - colliderHeightFromFloor), 10.5f);
MoveLimb(torso, new Vector2(ladderSimPos.X - 0.27f * Dir, Collider.SimPosition.Y + 0.5f - colliderHeightFromFloor), 10.5f);
MoveLimb(waist, new Vector2(ladderSimPos.X - 0.35f * Dir, Collider.SimPosition.Y + 0.4f - colliderHeightFromFloor), 10.5f);
MoveLimb(head, new Vector2(ladderSimPos.X - 0.27f * Dir, Collider.SimPosition.Y + 0.9f - colliderHeightFromFloor), 10.5f);
MoveLimb(torso, new Vector2(ladderSimPos.X - 0.27f * Dir, Collider.SimPosition.Y + 0.7f - colliderHeightFromFloor), 10.5f);
MoveLimb(waist, new Vector2(ladderSimPos.X - 0.35f * Dir, Collider.SimPosition.Y + 0.6f - colliderHeightFromFloor), 10.5f);
if (!character.IsRemotePlayer)
{
@@ -764,9 +764,9 @@ namespace Barotrauma
Vector2 handPos = new Vector2(
ladderSimPos.X,
Collider.SimPosition.Y + 0.6f + movement.Y * 0.1f - ladderSimPos.Y);
Collider.SimPosition.Y + 0.8f + movement.Y * 0.1f - ladderSimPos.Y);
handPos.Y = Math.Min(-0.5f, handPos.Y) - colliderHeightFromFloor;
handPos.Y = Math.Min(-0.2f, handPos.Y) - colliderHeightFromFloor;
MoveLimb(leftHand,
new Vector2(handPos.X,
@@ -783,7 +783,7 @@ namespace Barotrauma
Vector2 footPos = new Vector2(
handPos.X - Dir * 0.05f,
Collider.SimPosition.Y + 0.7f - colliderHeightFromFloor - stepHeight * 2.7f - ladderSimPos.Y - 0.7f);
Collider.SimPosition.Y + 0.9f - colliderHeightFromFloor - stepHeight * 2.7f - ladderSimPos.Y - 0.7f);
//if (movement.Y < 0) footPos.Y += 0.05f;

View File

@@ -382,24 +382,16 @@ namespace Barotrauma
//buoyancy
Vector2 buoyancy = new Vector2(0, Mass * 9.6f);
//drag
Vector2 velDir = Vector2.Normalize(LinearVelocity);
Vector2 line = new Vector2((float)Math.Cos(body.Rotation), (float)Math.Sin(body.Rotation));
line *= Math.Max(height + radius*2, height);
Vector2 normal = new Vector2(-line.Y, line.X);
normal = Vector2.Normalize(-normal);
float dragDot = Math.Abs(Vector2.Dot(normal, velDir));
Vector2 dragForce = Vector2.Zero;
if (dragDot > 0)
if (LinearVelocity.LengthSquared() > 0.00001f)
{
//drag
Vector2 velDir = Vector2.Normalize(LinearVelocity);
float vel = LinearVelocity.Length() * 2.0f;
float drag = dragDot * vel * vel
* Math.Max(height + radius * 2, height);
dragForce = Math.Min(drag, Mass * 1000.0f) * -velDir;
//if (dragForce.Length() > 100.0f) { }
float drag = vel * vel * Math.Max(height + radius * 2, height);
dragForce = Math.Min(drag, Mass * 500.0f) * -velDir;
}
body.ApplyForce(dragForce + buoyancy);