From a3defd4f58b2fde8060b4f75b1a5a5b5b44b591c Mon Sep 17 00:00:00 2001 From: cg2121 Date: Sat, 4 Mar 2023 00:57:58 -0600 Subject: [PATCH] UI: Fix spacing helpers when rotated and flipped If the scene item was rotated greater than 45 degrees, and flipped vertically or horizontally, the spacing helpers would be drawn incorrectly. This fixes the issue by checking the scale before the rotation, instead of after. --- UI/window-basic-preview.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index 7fb8bd556..40d6bc85b 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -2506,6 +2506,23 @@ void OBSBasicPreview::DrawSpacingHelpers() groupOti.pos.x, groupOti.pos.y, 0.0f); } + // Switch top/bottom or right/left if scale is negative + if (oti.scale.x < 0.0f) { + vec3 l = left; + vec3 r = right; + + vec3_copy(&left, &r); + vec3_copy(&right, &l); + } + + if (oti.scale.y < 0.0f) { + vec3 t = top; + vec3 b = bottom; + + vec3_copy(&top, &b); + vec3_copy(&bottom, &t); + } + if (rot >= HELPER_ROT_BREAKPONT) { for (float i = HELPER_ROT_BREAKPONT; i <= 360.0f; i += 90.0f) { if (rot < i) @@ -2539,23 +2556,6 @@ void OBSBasicPreview::DrawSpacingHelpers() } } - // Switch top/bottom or right/left if scale is negative - if (oti.scale.x < 0.0f) { - vec3 l = left; - vec3 r = right; - - vec3_copy(&left, &r); - vec3_copy(&right, &l); - } - - if (oti.scale.y < 0.0f) { - vec3 t = top; - vec3 b = bottom; - - vec3_copy(&top, &b); - vec3_copy(&bottom, &t); - } - // Get sides of box transform left = GetTransformedPos(left.x, left.y, boxTransform); right = GetTransformedPos(right.x, right.y, boxTransform);