Avoid unnecessary WorldRotation in mover code
This commit is contained in:
@@ -118,6 +118,7 @@ namespace Content.Shared.Movement
|
|||||||
{
|
{
|
||||||
if (transform.GridID != GridId.Invalid)
|
if (transform.GridID != GridId.Invalid)
|
||||||
mover.LastGridAngle = transform.Parent!.WorldRotation;
|
mover.LastGridAngle = transform.Parent!.WorldRotation;
|
||||||
|
|
||||||
transform.WorldRotation = physicsComponent.LinearVelocity.GetDir().ToAngle();
|
transform.WorldRotation = physicsComponent.LinearVelocity.GetDir().ToAngle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -128,7 +129,9 @@ namespace Content.Shared.Movement
|
|||||||
// This is relative to the map / grid we're on.
|
// This is relative to the map / grid we're on.
|
||||||
var total = walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed;
|
var total = walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed;
|
||||||
|
|
||||||
var worldTotal = _relativeMovement ? transform.Parent!.WorldRotation.RotateVec(total) : total;
|
var parentRotation = transform.Parent!.WorldRotation;
|
||||||
|
|
||||||
|
var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total;
|
||||||
|
|
||||||
DebugTools.Assert(MathHelper.CloseToPercent(total.Length, worldTotal.Length));
|
DebugTools.Assert(MathHelper.CloseToPercent(total.Length, worldTotal.Length));
|
||||||
|
|
||||||
@@ -138,7 +141,7 @@ namespace Content.Shared.Movement
|
|||||||
if (transform.GridID == GridId.Invalid)
|
if (transform.GridID == GridId.Invalid)
|
||||||
worldTotal = mover.LastGridAngle.RotateVec(worldTotal);
|
worldTotal = mover.LastGridAngle.RotateVec(worldTotal);
|
||||||
else
|
else
|
||||||
mover.LastGridAngle = transform.Parent!.WorldRotation;
|
mover.LastGridAngle = parentRotation;
|
||||||
|
|
||||||
if (worldTotal != Vector2.Zero)
|
if (worldTotal != Vector2.Zero)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user