From 66c9e33db0b7f4a006337e25aebd3d305fb2cc01 Mon Sep 17 00:00:00 2001 From: Sahra-Zhou Date: Wed, 15 Mar 2023 00:30:55 -0700 Subject: [PATCH 1/2] resolve NaN value when trying to change scale value from zero to other numbers --- document-legacy/src/layers/shape_layer.rs | 2 +- .../portfolio/document/properties_panel/utility_functions.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/document-legacy/src/layers/shape_layer.rs b/document-legacy/src/layers/shape_layer.rs index 48873ba3d7..43236f7c37 100644 --- a/document-legacy/src/layers/shape_layer.rs +++ b/document-legacy/src/layers/shape_layer.rs @@ -59,7 +59,7 @@ impl LayerData for ShapeLayer { fn bounding_box(&self, transform: glam::DAffine2, _render_data: &RenderData) -> Option<[DVec2; 2]> { let mut subpath = self.shape.clone(); - if transform.matrix2 == DMat2::ZERO { + if transform.matrix2 == DMat2::ZERO || !transform.is_finite() { return None; } subpath.apply_affine(transform); diff --git a/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs b/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs index c78044470e..3c24e7ceb6 100644 --- a/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs +++ b/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs @@ -48,6 +48,9 @@ pub fn apply_transform_operation(layer: &Layer, transform_op: TransformOp, value // Find the delta transform let mut delta = layer.transform.inverse() * transform; + if !delta.is_finite() { + return layer.transform.to_cols_array(); + } // Preserve aspect ratio if matches!(transform_op, TransformOp::ScaleX | TransformOp::Width) && layer.preserve_aspect { @@ -1155,6 +1158,7 @@ impl DAffine2Utils for DAffine2 { } fn update_scale_x(self, new_width: f64) -> Self { + debug!("modify transform value {}", new_width); let scale_x = self.scale_x(); if scale_x != 0. { self * DAffine2::from_scale((new_width / scale_x, 1.).into()) From af952f633bca9b596e00ec04ddf4ac74440d8063 Mon Sep 17 00:00:00 2001 From: Sahra-Zhou Date: Wed, 15 Mar 2023 00:33:21 -0700 Subject: [PATCH 2/2] resolve NaN value when trying to change scale value from zero to other numbers --- .../portfolio/document/properties_panel/utility_functions.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs b/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs index 3c24e7ceb6..60ed8b06b7 100644 --- a/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs +++ b/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs @@ -1158,7 +1158,6 @@ impl DAffine2Utils for DAffine2 { } fn update_scale_x(self, new_width: f64) -> Self { - debug!("modify transform value {}", new_width); let scale_x = self.scale_x(); if scale_x != 0. { self * DAffine2::from_scale((new_width / scale_x, 1.).into())