From 867f7d01439ea764664021f00454f6ae547aa621 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 31 Dec 2024 14:12:23 -0600 Subject: [PATCH] Add local variables to simplify math. --- Source/Editor/Gizmo/UIEditorGizmo.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Gizmo/UIEditorGizmo.cs b/Source/Editor/Gizmo/UIEditorGizmo.cs index a7da826bd..aba177b7d 100644 --- a/Source/Editor/Gizmo/UIEditorGizmo.cs +++ b/Source/Editor/Gizmo/UIEditorGizmo.cs @@ -649,14 +649,16 @@ namespace FlaxEditor { var style = Style.Current; var control = uiControl.Control; + var rotation = control.Rotation; + var rotationInRadians = rotation * Mathf.DegreesToRadians; var rect = new Rectangle( (pos + - new Float2(resizeAxis.X * Mathf.Cos(Mathf.DegreesToRadians * control.Rotation) - resizeAxis.Y * Mathf.Sin(Mathf.DegreesToRadians * control.Rotation), - resizeAxis.Y * Mathf.Cos(Mathf.DegreesToRadians * control.Rotation) + resizeAxis.X * Mathf.Sin(Mathf.DegreesToRadians * control.Rotation)) * 10 * scale) - size * 0.5f, + new Float2(resizeAxis.X * Mathf.Cos(rotationInRadians) - resizeAxis.Y * Mathf.Sin(rotationInRadians), + resizeAxis.Y * Mathf.Cos(rotationInRadians) + resizeAxis.X * Mathf.Sin(rotationInRadians)) * 10 * scale) - size * 0.5f, size); // Find more correct cursor at different angles - var unwindRotation = Mathf.UnwindDegrees(control.Rotation); + var unwindRotation = Mathf.UnwindDegrees(rotation); if (unwindRotation is (>= 45 and < 135) or (> -135 and <= -45) ) { switch (cursor)