diff --git a/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs b/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs index 30a61a91..3e5e91e9 100644 --- a/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs +++ b/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs @@ -717,7 +717,23 @@ impl TableRowLayout for Affine2 { } fn format_transform_matrix(transform: &DAffine2) -> String { - let (scale, angle, translation) = transform.to_scale_angle_translation(); + let (scale, angle, translation) = if transform.matrix2.determinant().abs() <= f64::EPSILON { + let [col_0, col_1] = transform.matrix2.to_cols_array_2d().map(|[x, y]| DVec2::new(x, y)); + + let scale = DVec2::new(col_0.length(), col_1.length()); + + let rotation = if scale.x > f64::EPSILON { + col_0.y.atan2(col_0.x) + } else if scale.y > f64::EPSILON { + col_1.y.atan2(col_1.x) - std::f64::consts::FRAC_PI_2 + } else { + 0. + }; + + (scale, rotation, transform.translation) + } else { + transform.to_scale_angle_translation() + }; let rotation = if angle == -0. { 0. } else { angle.to_degrees() }; let round = |x: f64| (x * 1e3).round() / 1e3; diff --git a/editor/src/messages/tool/common_functionality/compass_rose.rs b/editor/src/messages/tool/common_functionality/compass_rose.rs index bedc1ca2..5e2ab4e0 100644 --- a/editor/src/messages/tool/common_functionality/compass_rose.rs +++ b/editor/src/messages/tool/common_functionality/compass_rose.rs @@ -27,6 +27,9 @@ impl CompassRose { .selected_nodes() .selected_visible_and_unlocked_layers(&document.network_interface) .filter_map(|layer| { + if transform.matrix2.determinant().abs() <= f64::EPSILON { + return None; + } document .metadata() .bounding_box_with_transform(layer, transform.inverse() * document.metadata().transform_to_viewport(layer)) diff --git a/editor/src/messages/tool/common_functionality/pivot.rs b/editor/src/messages/tool/common_functionality/pivot.rs index 343c5d88..7ba3e7c7 100644 --- a/editor/src/messages/tool/common_functionality/pivot.rs +++ b/editor/src/messages/tool/common_functionality/pivot.rs @@ -241,6 +241,9 @@ impl Pivot { .selected_nodes() .selected_visible_and_unlocked_layers(&document.network_interface) .filter_map(|layer| { + if transform.matrix2.determinant().abs() <= f64::EPSILON { + return None; + } document .metadata() .bounding_box_with_transform(layer, transform.inverse() * document.metadata().transform_to_viewport(layer))