Skip to content

Commit 3e362e6

Browse files
committed
Fix an assertion failure bug when scaling a line in the transform cage
1 parent e529f74 commit 3e362e6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

editor/src/messages/tool/common_functionality/transformation_cage.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,15 @@ impl SelectedEdges {
212212
let original_from_pivot = updated - pivot; // The original vector from the point to the pivot
213213
let mut scale_factor = new_from_pivot / original_from_pivot;
214214

215-
// Constrain should always scale by the same factor in x and y
215+
// Constrain should always scale by the same factor in x and y.
216+
// When one axis of `original_from_pivot` is near zero (e.g. for a line's degenerate bounding box),
217+
// the scale factor for that axis is numerically unstable, so we copy from the more stable axis.
216218
if constrain {
217-
// When the point is on the pivot, we simply copy the other axis.
218-
if original_from_pivot.x.abs() < 1e-5 {
219+
if original_from_pivot.x.abs() < original_from_pivot.y.abs() {
219220
scale_factor.x = scale_factor.y;
220-
} else if original_from_pivot.y.abs() < 1e-5 {
221+
} else {
221222
scale_factor.y = scale_factor.x;
222223
}
223-
224-
debug_assert!((scale_factor.x - scale_factor.y).abs() < 1e-5);
225224
}
226225

227226
if !(self.left || self.right || constrain) {

0 commit comments

Comments
 (0)