Cherry-picked 0ff9a3d (more ragdoll optimization)
This commit is contained in:
@@ -1101,22 +1101,19 @@ namespace Barotrauma
|
||||
|
||||
float tfloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
|
||||
float targetY = tfloorY + Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor;
|
||||
|
||||
if (Math.Abs(Collider.SimPosition.Y - targetY) > 0.01f && Collider.SimPosition.Y<targetY && !forceImmediate)
|
||||
|
||||
if (Math.Abs(Collider.SimPosition.Y - targetY) > 0.01f)
|
||||
{
|
||||
Vector2 newSpeed = Collider.LinearVelocity;
|
||||
newSpeed.Y = (targetY - Collider.SimPosition.Y)*5.0f;
|
||||
Collider.LinearVelocity = newSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 newSpeed = Collider.LinearVelocity;
|
||||
newSpeed.Y = 0.0f;
|
||||
Collider.LinearVelocity = newSpeed;
|
||||
Vector2 newPos = Collider.SimPosition;
|
||||
newPos.Y = targetY;
|
||||
Collider.SetTransform(newPos, Collider.Rotation);
|
||||
}
|
||||
if (forceImmediate)
|
||||
{
|
||||
Collider.LinearVelocity = new Vector2(Collider.LinearVelocity.X, 0);
|
||||
Collider.SetTransform(new Vector2(Collider.SimPosition.X, targetY), Collider.Rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
Collider.LinearVelocity = new Vector2(Collider.LinearVelocity.X, (targetY - Collider.SimPosition.Y) * 5.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1465,22 +1462,17 @@ namespace Barotrauma
|
||||
|
||||
private Vector2 GetFlowForce()
|
||||
{
|
||||
Vector2 limbPos = ConvertUnits.ToDisplayUnits(Limbs[0].SimPosition);
|
||||
Vector2 limbPos = Limbs[0].Position;
|
||||
|
||||
Vector2 force = Vector2.Zero;
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
{
|
||||
Gap gap = e as Gap;
|
||||
if (gap == null || gap.FlowTargetHull != currentHull || gap.LerpedFlowForce == Vector2.Zero) continue;
|
||||
if (gap.Open <= 0.0f || gap.FlowTargetHull != currentHull || gap.LerpedFlowForce == Vector2.Zero) continue;
|
||||
|
||||
Vector2 gapPos = gap.SimPosition;
|
||||
|
||||
float dist = Vector2.Distance(limbPos, gapPos);
|
||||
|
||||
force += Vector2.Normalize(gap.LerpedFlowForce) * (Math.Max(gap.LerpedFlowForce.Length() - dist, 0.0f) / 500.0f);
|
||||
}
|
||||
|
||||
if (force.Length() > 20.0f) return force;
|
||||
return force;
|
||||
}
|
||||
|
||||
|
||||
@@ -783,12 +783,6 @@ namespace Barotrauma
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (Level.Loaded != null && WorldPosition.Y < Level.MaxEntityDepth)
|
||||
{
|
||||
Spawner.AddToRemoveQueue(this);
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyStatusEffects(ActionType.Always, deltaTime, null);
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
@@ -851,6 +845,12 @@ namespace Barotrauma
|
||||
MathHelper.Clamp(body.LinearVelocity.X, -MaxVel, MaxVel),
|
||||
MathHelper.Clamp(body.LinearVelocity.Y, -MaxVel, MaxVel));
|
||||
}
|
||||
|
||||
if (CurrentHull == null && body.SimPosition.Y < ConvertUnits.ToSimUnits(Level.MaxEntityDepth))
|
||||
{
|
||||
Spawner.AddToRemoveQueue(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateNetPosition();
|
||||
|
||||
Reference in New Issue
Block a user