(b651e55f4) Don't quantize physicsbody velocities server-side. Caused subs to occasionally not move horizontally because the velocities got rounded down to zero if the sub wasn't accelerating fast enough.
This commit is contained in:
@@ -383,7 +383,9 @@ namespace Barotrauma
|
|||||||
tempBuffer.Write(SimPosition.X);
|
tempBuffer.Write(SimPosition.X);
|
||||||
tempBuffer.Write(SimPosition.Y);
|
tempBuffer.Write(SimPosition.Y);
|
||||||
float MaxVel = NetConfig.MaxPhysicsBodyVelocity;
|
float MaxVel = NetConfig.MaxPhysicsBodyVelocity;
|
||||||
AnimController.Collider.LinearVelocity = NetConfig.Quantize(AnimController.Collider.LinearVelocity, -MaxVel, MaxVel, 12);
|
AnimController.Collider.LinearVelocity = new Vector2(
|
||||||
|
MathHelper.Clamp(AnimController.Collider.LinearVelocity.X, -MaxVel, MaxVel),
|
||||||
|
MathHelper.Clamp(AnimController.Collider.LinearVelocity.Y, -MaxVel, MaxVel));
|
||||||
tempBuffer.WriteRangedSingle(AnimController.Collider.LinearVelocity.X, -MaxVel, MaxVel, 12);
|
tempBuffer.WriteRangedSingle(AnimController.Collider.LinearVelocity.X, -MaxVel, MaxVel, 12);
|
||||||
tempBuffer.WriteRangedSingle(AnimController.Collider.LinearVelocity.Y, -MaxVel, MaxVel, 12);
|
tempBuffer.WriteRangedSingle(AnimController.Collider.LinearVelocity.Y, -MaxVel, MaxVel, 12);
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ namespace Barotrauma
|
|||||||
if (FarseerBody.Awake)
|
if (FarseerBody.Awake)
|
||||||
{
|
{
|
||||||
body.Enabled = true;
|
body.Enabled = true;
|
||||||
body.LinearVelocity = NetConfig.Quantize(body.LinearVelocity, -MaxVel, MaxVel, 12);
|
body.LinearVelocity = new Vector2(
|
||||||
|
MathHelper.Clamp(body.LinearVelocity.X, -MaxVel, MaxVel),
|
||||||
|
MathHelper.Clamp(body.LinearVelocity.Y, -MaxVel, MaxVel));
|
||||||
msg.WriteRangedSingle(body.LinearVelocity.X, -MaxVel, MaxVel, 12);
|
msg.WriteRangedSingle(body.LinearVelocity.X, -MaxVel, MaxVel, 12);
|
||||||
msg.WriteRangedSingle(body.LinearVelocity.Y, -MaxVel, MaxVel, 12);
|
msg.WriteRangedSingle(body.LinearVelocity.Y, -MaxVel, MaxVel, 12);
|
||||||
if (!FarseerBody.FixedRotation)
|
if (!FarseerBody.FixedRotation)
|
||||||
{
|
{
|
||||||
body.AngularVelocity = NetConfig.Quantize(body.AngularVelocity, -MaxAngularVel, MaxAngularVel, 8);
|
body.AngularVelocity = MathHelper.Clamp(body.AngularVelocity, -MaxAngularVel, MaxAngularVel);
|
||||||
msg.WriteRangedSingle(MathHelper.Clamp(body.AngularVelocity, -MaxAngularVel, MaxAngularVel), -MaxAngularVel, MaxAngularVel, 8);
|
msg.WriteRangedSingle(body.AngularVelocity, -MaxAngularVel, MaxAngularVel, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user