From 4db7fc1bf01d0f868411193d431617df3bbe6730 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Thu, 10 Feb 2022 04:37:00 +1300 Subject: [PATCH] Fix minor clickmap bug (#6596) --- Content.Client/Clickable/ClickableComponent.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Content.Client/Clickable/ClickableComponent.cs b/Content.Client/Clickable/ClickableComponent.cs index 5cb03a5d60..8a6f8f6ada 100644 --- a/Content.Client/Clickable/ClickableComponent.cs +++ b/Content.Client/Clickable/ClickableComponent.cs @@ -43,6 +43,17 @@ namespace Content.Client.Clickable var transform = _entMan.GetComponent(Owner); var worldRot = transform.WorldRotation; + + // We need to convert world angle to a positive value. between 0 and 2pi. This is important for + // CalcRectWorldAngle to get the right angle. Otherwise can get incorrect results for sprites at angles like + // -135 degrees (seems highly specific, but AI actors & other entities can snap to those angles while + // moving). As to why we treat world-angle like this, but not eye angle or world+eye, it is just because + // thats what sprite-rendering does. + worldRot = worldRot.Reduced(); + + if (worldRot.Theta < 0) + worldRot = new Angle(worldRot.Theta + Math.Tau); + var invSpriteMatrix = Matrix3.CreateTransform(Vector2.Zero, -sprite.Rotation, (1,1)/sprite.Scale); var relativeRotation = worldRot + _eyeManager.CurrentEye.Rotation;