RigidbodySync.GetFromAttached: store AttachedRigidbody.GetPosition() in local var

This commit is contained in:
JohnCorby 2022-03-11 01:06:34 -08:00
parent ad2c84acb2
commit 99cf46a23f
2 changed files with 6 additions and 4 deletions

View File

@ -70,9 +70,10 @@ public abstract class SectoredRigidbodySync : BaseSectoredSync
return;
}
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());
var pos = AttachedRigidbody.GetPosition();
transform.position = ReferenceTransform.ToRelPos(pos);
transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation());
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition());
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), pos);
AngularVelocity = ReferenceRigidbody.ToRelAngVel(AttachedRigidbody.GetAngularVelocity());
}

View File

@ -64,9 +64,10 @@ public abstract class UnsectoredRigidbodySync : BaseUnsectoredSync
protected override void GetFromAttached()
{
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());
var pos = AttachedRigidbody.GetPosition();
transform.position = ReferenceTransform.ToRelPos(pos);
transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation());
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition());
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), pos);
AngularVelocity = ReferenceRigidbody.ToRelAngVel(AttachedRigidbody.GetAngularVelocity());
}