fix: Transform Local Fields Being Miscalculated

This commit is contained in:
Syntriax 2024-11-02 13:47:08 +03:00
parent 9f522bdb66
commit 8eb34a0a6d
1 changed files with 4 additions and 4 deletions

View File

@ -52,7 +52,7 @@ public class Transform : ITransform
public Vector2D Scale public Vector2D Scale
{ {
get => _scale; get => _localScale.Scale(Parent?.Scale ?? Vector2D.One);
set set
{ {
if (value == _scale) if (value == _scale)
@ -66,7 +66,7 @@ public class Transform : ITransform
public float Rotation public float Rotation
{ {
get => _rotation; get => _localRotation * (Parent?.Rotation ?? 1f);
set set
{ {
if (value == _rotation) if (value == _rotation)
@ -239,9 +239,9 @@ public class Transform : ITransform
private void UpdatePosition() private void UpdatePosition()
{ {
if (Parent is null) if (Parent is null)
_position = LocalPosition.Scale(Vector2D.One).Rotate(0f * Math.DegreeToRadian); _position = LocalPosition.Rotate(0f * Math.DegreeToRadian);
else else
_position = Parent.Position + LocalPosition.Scale(new(1f / Parent.Scale.X, 1f / Parent.Scale.Y)).Rotate(Parent.Rotation * Math.DegreeToRadian); _position = Parent.Position + LocalPosition.Scale(new(Parent.Scale.X, Parent.Scale.Y)).Rotate(Parent.Rotation * Math.DegreeToRadian);
} }
private void UpdateScale() private void UpdateScale()