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 <priyaayadav@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Priyanshu 2025-03-01 12:48:01 +05:30 committed by GitHub
parent 17215ea66f
commit 778f589918
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -702,6 +702,9 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> 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 },