More physics error checks, ragdoll clamps the velocity returned by PhysicsBody.CorrectPosition to prevent applying excessively high velocities to the collider if the position has changed significantly between frames

This commit is contained in:
Joonas Rikkonen
2018-07-23 17:58:02 +03:00
parent a373c589d1
commit 25a62b3a51
3 changed files with 58 additions and 18 deletions
@@ -463,30 +463,32 @@ namespace Barotrauma
body.ApplyTorque(torque);
}
public void SetTransform(Vector2 simPosition, float rotation)
public bool SetTransform(Vector2 simPosition, float rotation)
{
System.Diagnostics.Debug.Assert(MathUtils.IsValid(simPosition));
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.X) < 1000000.0f);
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.Y) < 1000000.0f);
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) return;
if (!IsValidValue(rotation, "rotation")) return;
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) return false;
if (!IsValidValue(rotation, "rotation")) return false;
body.SetTransform(simPosition, rotation);
SetPrevTransform(simPosition, rotation);
return true;
}
public void SetTransformIgnoreContacts(Vector2 simPosition, float rotation)
public bool SetTransformIgnoreContacts(Vector2 simPosition, float rotation)
{
System.Diagnostics.Debug.Assert(MathUtils.IsValid(simPosition));
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.X) < 1000000.0f);
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.Y) < 1000000.0f);
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) return;
if (!IsValidValue(rotation, "rotation")) return;
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) return false;
if (!IsValidValue(rotation, "rotation")) return false;
body.SetTransformIgnoreContacts(ref simPosition, rotation);
SetPrevTransform(simPosition, rotation);
return true;
}
public void SetPrevTransform(Vector2 simPosition, float rotation)