From 778f589918bdf403b2af343ccb8ca6f373120b61 Mon Sep 17 00:00:00 2001 From: Priyanshu <129358934+indierusty@users.noreply.github.com> Date: Sat, 1 Mar 2025 12:48:01 +0530 Subject: [PATCH] Add a workaround to prevent nudge resizing from giving lines a NaN scale (#2331) * fix nudging the transform of 0 scaled object to `Nan` value by avoid division by zero vec2 * Update editor/src/messages/portfolio/document/document_message_handler.rs --------- Co-authored-by: indierusty Co-authored-by: Keavon Chambers --- .../messages/portfolio/document/document_message_handler.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 10b11790..99f4ab12 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -702,6 +702,9 @@ impl MessageHandler> for DocumentMessag }; let size = existing_bottom_right - existing_top_left; + // TODO: This is a hacky band-aid. It still results in the shape becoming zero-sized. Properly fix this using the correct math. + // If size is zero we clamp it to minimun value to avoid dividing by zero vector to calculate enlargement. + let size = size.max(DVec2::ONE); let enlargement = DVec2::new( if resize_opposite_corner != opposite_x { -delta_x } else { delta_x }, if resize_opposite_corner != opposite_y { -delta_y } else { delta_y },