From 51682d91b4b55e71851d4581e2e00996de287c1a Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 14 Nov 2026 20:44:52 -0600 Subject: [PATCH 1/3] Warp Cylinder: the bottom handle sets the lower depth only, corners keep the depth in pixels, wrap 0.9, square handles (#12513) --- .../src/tools/transform_tool/cylinder.rs | 60 +++++++++------- .../transform_tool/cylinder_handles_tests.rs | 70 +++++++++++++++++++ .../ui-egui/src/tools/transform_tool/tests.rs | 34 +++++---- 3 files changed, 126 insertions(+), 38 deletions(-) create mode 100644 crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs diff --git a/crates/ui-egui/src/tools/transform_tool/cylinder.rs b/crates/ui-egui/src/tools/transform_tool/cylinder.rs index 7869625d2c6..f862003e75f 100644 --- a/crates/ui-egui/src/tools/transform_tool/cylinder.rs +++ b/crates/ui-egui/src/tools/transform_tool/cylinder.rs @@ -10,9 +10,9 @@ //! as compared on #9798. The wrapped picture is outlined and cut into a 3 × 2 grid: two //! horizontal curves and the vertical centre line, which the bend and wrap handles work from. //! Squares at the top-right and the bottom-left corner each move their silhouette and edge -//! (the opposite corner stays put). The handle in the middle of the upper arc sets the bend of -//! both arcs (and so its own height); the one in the middle of the lower arc sets the lower -//! edge's height. The handle at the centre of the grid slides to the right, stretching the +//! (the opposite corner stays put), and both arcs keep their depth in pixels (#12513). The handle +//! in the middle of the upper arc sets the bend of both arcs (and so its own height); the one in +//! the middle of the lower arc sets the lower arc's depth alone (#12513). The handle at the centre of the grid slides to the right, stretching the //! middle of the picture and squeezing its sides further round the back (the wrap). A drag //! anywhere else on the cylinder moves the whole of it. The options bar keeps Bend, H and V //! greyed, as for a custom warp, and a cylinder has no splits and no grid menu. @@ -28,7 +28,8 @@ pub(super) enum CylinderHandle { Corner(usize), /// The middle of the upper arc: the bend of both arcs follows it up and down. Bend, - /// The middle of the lower arc: the lower edge follows it up and down (the height). + /// The middle of the lower arc: the lower arc's depth follows it up and down; the lower edge + /// and corners stay put (#12513). Bottom, /// The centre of the grid: dragged to the right, it stretches the middle of the picture and /// squeezes its sides round the back. @@ -41,8 +42,9 @@ pub(super) enum CylinderHandle { /// a quarter of the width, as the reference starts. const DEFAULT_DEPTH: f64 = 0.5; -/// How far the wrap handle starts along its travel from the centre: about 15 %, as the reference. -const DEFAULT_WRAP_POS: f64 = 0.15; +/// How far the wrap handle starts along its travel from the centre: 10 %, so a fresh cylinder +/// stores wrap 0.9, as measured (#12513: on a 400 px box the handle sits 20 px right of centre). +const DEFAULT_WRAP_POS: f64 = 0.1; /// The silhouettes never cross, nor do the edges: the moved one stops this far (document px) /// short of the other. @@ -113,8 +115,9 @@ pub(super) fn cylinder_hit(w: &Warp, p: [f64; 2], tol: f64) -> Option [f64; 7] { @@ -141,7 +144,9 @@ pub(super) fn cylinder_dragged(v0: [f64; 7], handle: CylinderHandle, d: [f64; 2] v[4] = depth_dragged(v0[4], step); v[5] = depth_dragged(v0[5], step); } - CylinderHandle::Bottom => v[1] += d[1], + // Only the lower arc's depth, by the drag over the half axis (#12513: +40 px on a 400 px + // cylinder takes 0.5 to about 0.7); the lower edge and its corners stay put. + CylinderHandle::Bottom => v[5] = depth_dragged(v0[5], d[1] / a), CylinderHandle::Wrap => v[6] = wrap_of_pos(pos_of_wrap(v0[6]) + d[0] / a), CylinderHandle::Surface => { v[0] += d[0]; @@ -169,6 +174,17 @@ pub(super) fn cylinder_dragged(v0: [f64; 7], handle: CylinderHandle, d: [f64; 2] v[1] = v[3] + MIN_SIDE; } } + // A corner keeps both arcs' depth in document pixels (#12513): in half-axis units each depth + // grows as the half axis shrinks (200 → 189.75 px takes 0.5 to 0.527). + if matches!(handle, CylinderHandle::Corner(_)) { + let a1 = ((v[2] - v[0]) / 2.0).max(MIN_SIDE / 2.0); + let k = a / a1; + for i in [4, 5] { + // Within the half axis, or its own reach when a file put it past that. + let limit = DEPTH_LIMIT.max(v0[i].abs()); + v[i] = (v0[i] * k).clamp(-limit, limit); + } + } v } @@ -218,8 +234,7 @@ pub(super) fn cylinder_cursor(w: &Warp, p: [f64; 2], tol: f64, xf: &ViewXform) - } /// The cylinder's outline, its 3 × 2 grid (two horizontal curves and the centre line) and its -/// handles: squares at the two corners, circles in the middle of each arc, a diamond for the -/// wrap; the one being dragged is filled with the lines' colour. `curve(u, v)` traces the mesh +/// handles, all small squares (#12513); the one being dragged is filled with the lines' colour. `curve(u, v)` traces the mesh /// along a fixed `u` or `v`. pub(super) fn draw_cylinder( painter: &egui::Painter, @@ -243,20 +258,13 @@ pub(super) fn draw_cylinder( for (q, h) in cylinder_handles(&v) { let p = scr(q); let fill = if dragged == Some(h) { line.color } else { Color32::WHITE }; - match h { - CylinderHandle::Bend | CylinderHandle::Bottom => { - painter.circle_filled(p, 3.5, fill); - painter.circle_stroke(p, 3.5, line); - } - CylinderHandle::Wrap => { - let pts = vec![p - vec2(0.0, 5.0), p + vec2(5.0, 0.0), p + vec2(0.0, 5.0), p - vec2(5.0, 0.0)]; - painter.add(egui::Shape::convex_polygon(pts, fill, line)); - } - _ => { - let r = egui::Rect::from_center_size(p, vec2(7.0, 7.0)); - painter.rect_filled(r, 0.0, fill); - painter.rect_stroke(r, 0.0, line, egui::StrokeKind::Inside); - } - } + // All five are small squares, as the reference draws them (#12513). + let r = egui::Rect::from_center_size(p, vec2(7.0, 7.0)); + painter.rect_filled(r, 0.0, fill); + painter.rect_stroke(r, 0.0, line, egui::StrokeKind::Inside); } } + +#[cfg(test)] +#[path = "cylinder_handles_tests.rs"] +mod cylinder_handles_tests; diff --git a/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs b/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs new file mode 100644 index 00000000000..fbeca6685f6 --- /dev/null +++ b/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs @@ -0,0 +1,70 @@ +//! #12513: the Cylinder's handles as measured in the reference application, on a 400 × 300 box at +//! (200, 150): a fresh cylinder stores wrap 0.9; the bottom-centre handle changes only the lower +//! arc's depth; a corner keeps both arcs' depth in pixels; all five handles are squares. + +use super::*; + +const BOX: [f64; 4] = [200.0, 150.0, 600.0, 450.0]; + +fn close(a: f64, b: f64, tol: f64) -> bool { + (a - b).abs() <= tol +} + +#[test] +fn a_fresh_cylinder_stores_wrap_0_9_with_its_handle_20_px_right_of_centre() { + let v = cylinder_values(&cylinder_default(BOX).unwrap()).unwrap(); + assert_eq!(&v[..6], &[200.0, 450.0, 600.0, 150.0, 0.5, 0.5]); + assert!(close(v[6], 0.9, 1e-9), "{v:?}"); + let wrap = cylinder_handles(&v)[4].0; + assert!(close(wrap[0], 420.0, 1e-9), "measured at x 421: {wrap:?}"); +} + +#[test] +fn the_bottom_handle_changes_only_the_lower_arcs_depth() { + let v0 = cylinder_values(&cylinder_default(BOX).unwrap()).unwrap(); + let v = cylinder_dragged(v0, CylinderHandle::Bottom, [0.0, 40.0]); + assert_eq!([v[0], v[1], v[2], v[3], v[4], v[6]], [200.0, 450.0, 600.0, 150.0, 0.5, v0[6]], "edges, corners and the top arc stay"); + assert!(close(v[5], 0.6975, 0.005), "measured 0.6975: {}", v[5]); + let front = cylinder_handles(&v)[3].0; + assert!(close(front[1], 590.0, 1.0), "the arc's front moves to y 590: {front:?}"); +} + +#[test] +fn a_corner_keeps_both_arcs_depth_in_pixels() { + // From the measured depths 0.5 / 0.6975, the top-right corner dragged (-20, -20). + let v0 = [200.0, 450.0, 600.0, 150.0, 0.5, 0.6975, 0.9]; + let v = cylinder_dragged(v0, CylinderHandle::Corner(1), [-20.0, -20.0]); + assert_eq!([v[0], v[1], v[2], v[3]], [200.0, 450.0, 580.0, 130.0]); + assert!(close(v[4], 0.527, 0.005) && close(v[5], 0.735, 0.005), "measured 0.527 / 0.735: {v:?}"); + // In pixels the arcs are as deep as before. + let (a0, a1) = (200.0, 190.0); + assert!(close(v[4] * a1, v0[4] * a0, 1e-9) && close(v[5] * a1, v0[5] * a0, 1e-9)); + assert_eq!(v[6], 0.9, "the wrap stays"); +} + +#[test] +fn a_drag_inside_moves_the_whole_cylinder_with_its_values() { + let v0 = cylinder_values(&cylinder_default(BOX).unwrap()).unwrap(); + let v = cylinder_dragged(v0, CylinderHandle::Surface, [15.0, -10.0]); + assert_eq!(v, [215.0, 440.0, 615.0, 140.0, v0[4], v0[5], v0[6]]); +} + +#[test] +fn all_five_handles_are_squares() { + let ctx = egui::Context::default(); + // A real preview: a layer in Warp mode. + let mut app = super::super::tests::app_with_square(800, photocraft_geom::Rect::new(200, 150, 600, 450)); + super::super::begin_warp(&mut app, &ctx).unwrap(); + let pv = app.transform_preview.as_ref().expect("the preview"); + let w = cylinder_default(BOX).unwrap(); + let line = Stroke::new(1.0, Color32::from_rgb(40, 120, 220)); + let mut o = ctx.run_ui(Default::default(), |ui| { + draw_cylinder(ui.painter(), &w, |_, _| Vec::new(), |q| egui::pos2(q[0] as f32 / 4.0, q[1] as f32 / 4.0), pv, line); + }); + o.textures_delta.clear(); + let shapes: Vec<&egui::Shape> = o.shapes.iter().map(|c| &c.shape).collect(); + let rects = shapes.iter().filter(|s| matches!(s, egui::Shape::Rect(_))).count(); + assert!(rects >= 5, "a filled and stroked square per handle: {rects}"); + assert!(!shapes.iter().any(|s| matches!(s, egui::Shape::Circle(_))), "no circles"); + assert!(!shapes.iter().any(|s| matches!(s, egui::Shape::Path(p) if p.points.len() == 4 && p.closed)), "no diamond"); +} diff --git a/crates/ui-egui/src/tools/transform_tool/tests.rs b/crates/ui-egui/src/tools/transform_tool/tests.rs index 754b8b2789a..080125d25b3 100644 --- a/crates/ui-egui/src/tools/transform_tool/tests.rs +++ b/crates/ui-egui/src/tools/transform_tool/tests.rs @@ -3820,7 +3820,7 @@ fn the_warp_menu_lists_cylinder_after_the_presets_except_on_type() { /// The cylinder the menu starts with, as the reference starts it: its four corners on the box, /// both arcs half the half axis deep (a quarter of the width), so the lower one hangs below the -/// box, and the wrap handle 15 % along its travel. +/// box, and the wrap handle 10 % along its travel (wrap 0.9, #12513). #[test] fn the_warp_menus_cylinder_starts_on_the_box_corners() { let b = [8.0, 8.0, 32.0, 32.0]; @@ -3828,9 +3828,9 @@ fn the_warp_menus_cylinder_starts_on_the_box_corners() { assert_eq!(w.style, WarpStyle::Cylinder); let v = cylinder_values(&w).unwrap(); assert_eq!(&v[..6], &[8.0, 32.0, 32.0, 8.0, 0.5, 0.5]); - assert!((v[6] - 0.85).abs() < 1e-9, "{v:?}"); + assert!((v[6] - 0.9).abs() < 1e-9, "{v:?}"); let wrap = cylinder_handles(&v)[4].0; - assert!((wrap[0] - (20.0 + 0.15 * 12.0)).abs() < 1e-9, "the wrap handle starts 15 % of the half axis right of the centre: {wrap:?}"); + assert!((wrap[0] - (20.0 + 0.1 * 12.0)).abs() < 1e-9, "the wrap handle starts 10 % of the half axis right of the centre: {wrap:?}"); let cb = w.mesh.as_ref().unwrap().control_bounds(); assert!(cb[0] >= 8.0 - 1e-9 && cb[2] <= 32.0 + 1e-9 && cb[1] >= 8.0 - 1e-9, "{cb:?}"); assert!(cb[3] > 32.0 + 5.0, "the lower arc's front hangs about 6 px below the box: {cb:?}"); @@ -3873,9 +3873,15 @@ fn cylinder_handles_are_two_corners_the_arcs_and_the_wrap() { #[test] fn cylinder_drags_set_its_values_and_keep_them_sound() { let v = [10.0, 40.0, 60.0, 10.0, 0.3, 0.3, 0.5]; - // A corner takes its silhouette and its edge along; the opposite corner stays put. - assert_eq!(cylinder_dragged(v, CylinderHandle::Corner(1), [2.0, 3.0]), [10.0, 40.0, 62.0, 13.0, 0.3, 0.3, 0.5]); - assert_eq!(cylinder_dragged(v, CylinderHandle::Corner(3), [-2.0, 3.0]), [8.0, 43.0, 60.0, 10.0, 0.3, 0.3, 0.5]); + // A corner takes its silhouette and its edge along; the opposite corner stays put, and the arcs + // keep their depth in pixels (#12513): a half axis of 25 → 26 px takes 0.3 to 0.3 × 25 / 26. + let k = 0.3 * 25.0 / 26.0; + let d = cylinder_dragged(v, CylinderHandle::Corner(1), [2.0, 3.0]); + assert_eq!(d[..4], [10.0, 40.0, 62.0, 13.0]); + assert!((d[4] - k).abs() < 1e-9 && (d[5] - k).abs() < 1e-9 && d[6] == 0.5, "{d:?}"); + let d = cylinder_dragged(v, CylinderHandle::Corner(3), [-2.0, 3.0]); + assert_eq!(d[..4], [8.0, 43.0, 60.0, 10.0]); + assert!((d[4] - k).abs() < 1e-9 && (d[5] - k).abs() < 1e-9, "{d:?}"); // The bend handle follows the pointer and bends both arcs: 5 px down on a 25 px half axis // is 0.2 deeper. let d = cylinder_dragged(v, CylinderHandle::Bend, [0.0, 5.0]); @@ -3891,8 +3897,10 @@ fn cylinder_drags_set_its_values_and_keep_them_sound() { // A move keeps the shape, however narrow the cylinder. let narrow = [10.0, 40.0, 10.5, 10.0, 0.3, 0.3, 0.5]; assert_eq!(cylinder_dragged(narrow, CylinderHandle::Surface, [5.0, 0.0]), [15.0, 40.0, 15.5, 10.0, 0.3, 0.3, 0.5]); - // The bottom handle moves the lower edge; the arc keeps its depth. - assert_eq!(cylinder_dragged(v, CylinderHandle::Bottom, [7.0, 6.0]), [10.0, 46.0, 60.0, 10.0, 0.3, 0.3, 0.5]); + // The bottom handle sets the lower arc's depth alone (#12513): 6 px down on a 25 px half axis. + let d = cylinder_dragged(v, CylinderHandle::Bottom, [7.0, 6.0]); + assert_eq!([d[0], d[1], d[2], d[3], d[4], d[6]], [10.0, 40.0, 60.0, 10.0, 0.3, 0.5]); + assert!((d[5] - (0.3 + 6.0 / 25.0)).abs() < 1e-9, "{d:?}"); // The wrap handle follows the pointer along the half axis: right stretches the middle (wrap down). let d = cylinder_dragged(v, CylinderHandle::Wrap, [6.25, 0.0]); assert!((d[6] - 0.25).abs() < 1e-9, "{d:?}"); @@ -3905,7 +3913,8 @@ fn cylinder_drags_set_its_values_and_keep_them_sound() { assert_eq!([d[0], d[2], d[1], d[3]], [59.0, 60.0, 11.0, 10.0]); let d = cylinder_dragged(v, CylinderHandle::Corner(1), [-80.0, 60.0]); assert_eq!([d[0], d[2], d[1], d[3]], [10.0, 11.0, 40.0, 39.0]); - assert_eq!(cylinder_dragged(v, CylinderHandle::Bottom, [0.0, -80.0])[1], 11.0); + let d = cylinder_dragged(v, CylinderHandle::Bottom, [0.0, -80.0]); + assert_eq!((d[1], d[5]), (40.0, -1.0), "the lower edge stays; the depth stops at the half axis"); // Whatever the drag, the result is a cylinder the geometry accepts. for h in [CylinderHandle::Corner(1), CylinderHandle::Corner(3), CylinderHandle::Bend, CylinderHandle::Bottom, CylinderHandle::Wrap, CylinderHandle::Surface] { @@ -3947,7 +3956,8 @@ fn warp_mode_drags_a_cylinders_handles_and_commits_it_as_a_cylinder() { warp_pointer(&mut app, ToolEvent::Down { x: wrap[0], y: wrap[1], pressure: 1.0 }, 2.0, mods); assert!(matches!(app.transform_preview.as_ref().unwrap().warp_drag, Some(WarpDrag::Cylinder { handle: CylinderHandle::Wrap, .. }))); warp_pointer(&mut app, ToolEvent::Up { x: wrap[0] + 3.0, y: wrap[1] }, 2.0, mods); - assert!((cylinder_of(&app)[6] - 0.6).abs() < 1e-9, "{:?}", cylinder_of(&app)); + // From the 0.9 a fresh cylinder starts with (#12513), a quarter of the travel less. + assert!((cylinder_of(&app)[6] - 0.65).abs() < 1e-9, "{:?}", cylinder_of(&app)); assert!((cylinder_handles(&cylinder_of(&app))[4].0[0] - (wrap[0] + 3.0)).abs() < 1e-9, "the wrap handle followed the pointer"); track_steps(&mut app, &ctx); // A drag on the surface moves the whole cylinder. @@ -3967,9 +3977,9 @@ fn warp_mode_drags_a_cylinders_handles_and_commits_it_as_a_cylinder() { let _ = intercept(&mut app, "edit.undo"); assert_eq!(cylinder_of(&app), before, "undo takes back the move"); let _ = intercept(&mut app, "edit.undo"); - assert!((cylinder_of(&app)[6] - 0.85).abs() < 1e-9, "undo takes back the wrap: {:?}", cylinder_of(&app)); + assert!((cylinder_of(&app)[6] - 0.9).abs() < 1e-9, "undo takes back the wrap: {:?}", cylinder_of(&app)); let _ = intercept(&mut app, "edit.redo"); - assert!((cylinder_of(&app)[6] - 0.6).abs() < 1e-9, "redo: {:?}", cylinder_of(&app)); + assert!((cylinder_of(&app)[6] - 0.65).abs() < 1e-9, "redo: {:?}", cylinder_of(&app)); let v = cylinder_of(&app); let steps = app.session.active().unwrap().history.past_len(); commit(&mut app); From 3c7469ce0cc83fea20aa8b9dcb4a5fbaca2be80e Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 14 Nov 2026 23:54:34 -0600 Subject: [PATCH 2/3] Cylinder corner: say that pixel depth holds up to the half axis, with a test --- .../src/tools/transform_tool/cylinder.rs | 8 ++++++-- .../transform_tool/cylinder_handles_tests.rs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tools/transform_tool/cylinder.rs b/crates/ui-egui/src/tools/transform_tool/cylinder.rs index f862003e75f..5dc54429287 100644 --- a/crates/ui-egui/src/tools/transform_tool/cylinder.rs +++ b/crates/ui-egui/src/tools/transform_tool/cylinder.rs @@ -10,7 +10,9 @@ //! as compared on #9798. The wrapped picture is outlined and cut into a 3 × 2 grid: two //! horizontal curves and the vertical centre line, which the bend and wrap handles work from. //! Squares at the top-right and the bottom-left corner each move their silhouette and edge -//! (the opposite corner stays put), and both arcs keep their depth in pixels (#12513). The handle +//! (the opposite corner stays put), and both arcs keep their depth in pixels (#12513) as long as it +//! fits the half axis: an arc is never dragged deeper than that (the reference was measured only +//! inside it), so a corner pulled far in stops the arcs at the half axis. The handle //! in the middle of the upper arc sets the bend of both arcs (and so its own height); the one in //! the middle of the lower arc sets the lower arc's depth alone (#12513). The handle at the centre of the grid slides to the right, stretching the //! middle of the picture and squeezing its sides further round the back (the wrap). A drag @@ -175,7 +177,9 @@ pub(super) fn cylinder_dragged(v0: [f64; 7], handle: CylinderHandle, d: [f64; 2] } } // A corner keeps both arcs' depth in document pixels (#12513): in half-axis units each depth - // grows as the half axis shrinks (200 → 189.75 px takes 0.5 to 0.527). + // grows as the half axis shrinks (200 → 189.75 px takes 0.5 to 0.527). Only up to the half axis + // ([`DEPTH_LIMIT`]), as for the other handles: a cylinder shrunk to half its width stops its + // arcs at 1.0 rather than keeping their pixels (not measured past that). if matches!(handle, CylinderHandle::Corner(_)) { let a1 = ((v[2] - v[0]) / 2.0).max(MIN_SIDE / 2.0); let k = a / a1; diff --git a/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs b/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs index fbeca6685f6..adc2817938e 100644 --- a/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs +++ b/crates/ui-egui/src/tools/transform_tool/cylinder_handles_tests.rs @@ -42,6 +42,25 @@ fn a_corner_keeps_both_arcs_depth_in_pixels() { assert_eq!(v[6], 0.9, "the wrap stays"); } +/// CodeRabbit on #15020: pixels are kept only while the depth fits the half axis. A corner dragged +/// 200 px in on a 400 px cylinder leaves a 100 px half axis; the lower arc (0.6975 of 200 px = +/// 139.5 px) would need 1.395 and stops at the half axis, 100 px, as the Bend and Bottom handles +/// do. The reference was measured only with arcs inside the half axis. +#[test] +fn a_corner_keeps_pixel_depth_only_up_to_the_half_axis() { + let v0 = [200.0, 450.0, 600.0, 150.0, 0.5, 0.6975, 0.9]; + let v = cylinder_dragged(v0, CylinderHandle::Corner(1), [-200.0, 0.0]); + assert_eq!([v[0], v[2]], [200.0, 400.0], "half axis 100 px"); + assert_eq!(v[5], 1.0, "the lower arc stops at the half axis (100 px), not 1.395: {v:?}"); + assert!(close(v[4], 1.0, 1e-9), "the upper arc (100 px of 200) reaches exactly the half axis: {v:?}"); + // A shrink that still fits keeps the pixels: 60 px in leaves a 170 px half axis. + let w = cylinder_dragged(v0, CylinderHandle::Corner(1), [-60.0, 0.0]); + assert!(close(w[5] * 170.0, 0.6975 * 200.0, 1e-9) && close(w[4] * 170.0, 0.5 * 200.0, 1e-9), "{w:?}"); + // A depth a file put past the half axis is kept as it was, not pulled in. + let past = cylinder_dragged([200.0, 450.0, 600.0, 150.0, 1.4, 0.5, 0.9], CylinderHandle::Corner(1), [-20.0, 0.0]); + assert!(close(past[4], 1.4, 1e-9), "its own reach: {past:?}"); +} + #[test] fn a_drag_inside_moves_the_whole_cylinder_with_its_values() { let v0 = cylinder_values(&cylinder_default(BOX).unwrap()).unwrap(); From e7e745462fc486736a8773b7f0ab9f45057697a7 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 22:33:40 +0100 Subject: [PATCH 3/3] Cylinder warp test: the wrap drag steps from the start's wrap, not a fixed 0.85 Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/transform_tool/tests.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tools/transform_tool/tests.rs b/crates/ui-egui/src/tools/transform_tool/tests.rs index a445c57098e..4a191509b95 100644 --- a/crates/ui-egui/src/tools/transform_tool/tests.rs +++ b/crates/ui-egui/src/tools/transform_tool/tests.rs @@ -1999,9 +1999,9 @@ fn warp_mode_drags_a_cylinders_handles_and_commits_it_as_a_cylinder() { settle(&mut app); // The wrap handle, dragged 3 px right: a quarter of the 12 px half axis further along. let mut wrapped = cylinder_of(&app); - wrapped[6] = 0.6; + wrapped[6] = v0[6] - 0.25; drag_cylinder(&mut app, 2, wrapped); - assert!((cylinder_of(&app)[6] - 0.6).abs() < 1e-9, "{:?}", cylinder_of(&app)); + assert!((cylinder_of(&app)[6] - wrapped[6]).abs() < 1e-9, "{:?}", cylinder_of(&app)); settle(&mut app); // A drag on the surface moves the whole cylinder. let before = cylinder_of(&app); @@ -2016,9 +2016,9 @@ fn warp_mode_drags_a_cylinders_handles_and_commits_it_as_a_cylinder() { let _ = intercept(&mut app, "edit.undo"); assert_eq!(cylinder_of(&app), before, "undo takes back the move"); let _ = intercept(&mut app, "edit.undo"); - assert!((cylinder_of(&app)[6] - 0.85).abs() < 1e-9, "undo takes back the wrap: {:?}", cylinder_of(&app)); + assert!((cylinder_of(&app)[6] - v0[6]).abs() < 1e-9, "undo takes back the wrap: {:?}", cylinder_of(&app)); let _ = intercept(&mut app, "edit.redo"); - assert!((cylinder_of(&app)[6] - 0.6).abs() < 1e-9, "redo: {:?}", cylinder_of(&app)); + assert!((cylinder_of(&app)[6] - wrapped[6]).abs() < 1e-9, "redo: {:?}", cylinder_of(&app)); let v = cylinder_of(&app); let steps = app.session.active().unwrap().history.past_len(); commit(&mut app);