Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Sketch: snap where two recent centre and midpoint guides meet (#8694) (#8744)

taylorhayis313d2bdb415a
diff --git a/assets/locales/pending/sketch-recent-snap.json b/assets/locales/pending/sketch-recent-snap.json
new file mode 100644
index 0000000000..6db5465309
--- /dev/null
+++ b/assets/locales/pending/sketch-recent-snap.json
@@ -0,0 +1,38 @@
+{
+ "en": {
+ "prefs.sketch_recent_snap": "Auto snap to recent centers and midpoints",
+ "prefs.sketch_recent_snap_note": "While drawing, snap the cursor where the guides of the two most recent circle centers or straight-edge midpoints cross. Off: those guides stay visual and the cursor does not move."
+ },
+ "en-GB": {
+ "prefs.sketch_recent_snap": "Auto snap to recent centres and midpoints",
+ "prefs.sketch_recent_snap_note": "While drawing, snap the cursor where the guides of the two most recent circle centres or straight-edge midpoints cross. Off: those guides stay visual and the cursor does not move."
+ },
+ "ja": {
+ "prefs.sketch_recent_snap": "最近使った中心と中点へ自動スナップ",
+ "prefs.sketch_recent_snap_note": "作図中、直前の2つの円の中心または直線辺の中点のガイドが交わる位置にカーソルをスナップします。オフ: ガイドは表示のみで、カーソルは移動しません。"
+ },
+ "zh": {
+ "prefs.sketch_recent_snap": "自动吸附到最近的圆心和中点",
+ "prefs.sketch_recent_snap_note": "绘图时,将光标吸附到最近两个圆心或直线边中点的辅助线相交处。关闭:辅助线仅作显示,光标不会移动。"
+ },
+ "de": {
+ "prefs.sketch_recent_snap": "Automatisch an zuletzt verwendete Mittelpunkte fangen",
+ "prefs.sketch_recent_snap_note": "Fängt den Zeiger beim Zeichnen dort ein, wo sich die Hilfslinien der beiden zuletzt verwendeten Kreismittelpunkte oder Kantenmitten kreuzen. Aus: die Hilfslinien bleiben sichtbar und der Zeiger bewegt sich nicht."
+ },
+ "ko": {
+ "prefs.sketch_recent_snap": "최근 중심과 중점에 자동 스냅",
+ "prefs.sketch_recent_snap_note": "그리는 동안 최근에 사용한 두 원의 중심 또는 직선 모서리 중점의 안내선이 만나는 위치로 커서를 스냅합니다. 끄기: 안내선은 보기만 하고 커서는 움직이지 않습니다."
+ },
+ "ar": {
+ "prefs.sketch_recent_snap": "الالتقاط التلقائي إلى المراكز ونقاط المنتصف الأخيرة",
+ "prefs.sketch_recent_snap_note": "أثناء الرسم، يلتقط المؤشر الموضع الذي يتقاطع فيه دليلا آخر مركزي دائرتين أو نقطتي منتصف حافتين مستقيمتين. إيقاف: تبقى الأدلة للعرض فقط ولا يتحرك المؤشر."
+ },
+ "he": {
+ "prefs.sketch_recent_snap": "הצמדה אוטומטית למרכזים ולנקודות אמצע אחרונים",
+ "prefs.sketch_recent_snap_note": "בזמן שרטוט, הסמן נצמד למקום שבו נחתכים קווי העזר של שני מרכזי המעגלים או נקודות האמצע של קצוות ישרים האחרונים. כבוי: קווי העזר נשארים לתצוגה בלבד והסמן אינו זז."
+ },
+ "vi": {
+ "prefs.sketch_recent_snap": "Tự động bắt điểm vào tâm và trung điểm gần đây",
+ "prefs.sketch_recent_snap_note": "Khi vẽ, con trỏ được bắt vào nơi các đường dẫn của hai tâm đường tròn hoặc trung điểm cạnh thẳng gần nhất cắt nhau. Tắt: các đường dẫn chỉ để xem và con trỏ không di chuyển."
+ }
+}
diff --git a/attribution/pending/sketch-recent-snap.md b/attribution/pending/sketch-recent-snap.md
new file mode 100644
index 0000000000..889ebf45d0
--- /dev/null
+++ b/attribution/pending/sketch-recent-snap.md
@@ -0,0 +1 @@
+| assets/locales/pending/sketch-recent-snap.json | SolidCraft contributors | Original preference messages for the recent centre and midpoint snap | MIT OR Apache-2.0 |
diff --git a/crates/ui-egui/src/inference.rs b/crates/ui-egui/src/inference.rs
index 69b59065dd..8ad9581717 100644
--- a/crates/ui-egui/src/inference.rs
+++ b/crates/ui-egui/src/inference.rs
@@ -250,13 +250,16 @@ pub fn show(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
}
}
-/// A hovered centre or straight-edge midpoint. Transient, per viewport, never a constraint.
+/// The two most recent hovered centres or straight-edge midpoints. Transient, per viewport,
+/// never a constraint. A third hover drops the oldest. Endpoints are ordinary point snaps.
#[derive(Default)]
pub(crate) struct Tracking {
sketch: Option<u64>,
document: std::sync::Weak<solidcraft_engine::doc::Document>,
anchor: Option<String>,
+ previous: Option<String>,
pub(crate) guide: Option<(Vec2, Vec2)>,
+ pub(crate) remembered_guide: Option<(Vec2, Vec2)>,
}
impl Tracking {
@@ -271,26 +274,91 @@ impl Tracking {
}
}
+ fn point_of(sk: &Sketch, id: &str) -> Option<Vec2> {
+ Self::reference(sk, sk.curve_index(id)?)
+ }
+
+ /// Keep `id` as one of the two remembered references. Hovering the older one swaps them,
+ /// so going back does not drop it. A third, different reference drops the oldest.
+ fn remember(&mut self, id: String) {
+ if self.anchor.as_deref() == Some(id.as_str()) {
+ return;
+ }
+ if self.previous.as_deref() == Some(id.as_str()) {
+ std::mem::swap(&mut self.anchor, &mut self.previous);
+ return;
+ }
+ self.previous = self.anchor.replace(id);
+ }
+
+ /// Where the horizontal through one reference meets the vertical through the other, when
+ /// that point is within a few pixels of the cursor and is not either reference itself.
+ pub(crate) fn meeting(&self, sk: &Sketch, plane: &solidcraft_engine::geom::Plane, proj: &Proj, cursor: egui::Pos2) -> Option<Vec2> {
+ let a = self.anchor.as_deref().and_then(|id| Self::point_of(sk, id))?;
+ let b = self.previous.as_deref().and_then(|id| Self::point_of(sk, id))?;
+ if a.dist(b) < 1e-6 {
+ return None;
+ }
+ let to = |p: Vec2| proj.to_screen(plane.to_world(p));
+ let mut best: Option<(f32, Vec2)> = None;
+ for at in [Vec2::new(a.x, b.y), Vec2::new(b.x, a.y)] {
+ if at.dist(a) < 1e-6 || at.dist(b) < 1e-6 {
+ continue;
+ }
+ let Some(screen) = to(at).filter(|p| proj.rect.contains(*p)) else { continue };
+ let distance = cursor.distance(screen);
+ if distance < 8.0 && best.is_none_or(|(d, _)| distance < d) {
+ best = Some((distance, at));
+ }
+ }
+ best.map(|(_, at)| at)
+ }
+
+ fn axis_guide(anchor: Vec2, at: Vec2, cursor: egui::Pos2, to: &impl Fn(Vec2) -> Option<egui::Pos2>) -> Option<(Vec2, Vec2)> {
+ let origin = to(anchor)?;
+ let mut distance = 6.0;
+ let mut end = None;
+ for candidate in [Vec2::new(at.x, anchor.y), Vec2::new(anchor.x, at.y)] {
+ let Some(screen) = to(candidate) else { continue };
+ let off_axis = cursor.distance(screen);
+ if origin.distance(screen) > 8.0 && off_axis < distance {
+ distance = off_axis;
+ end = Some(candidate);
+ }
+ }
+ end.map(|end| (anchor, end))
+ }
+
fn update(&mut self, sk: &Sketch, plane: &solidcraft_engine::geom::Plane, proj: &Proj, cursor: egui::Pos2) {
self.guide = None;
+ self.remembered_guide = None;
let to = |p: Vec2| proj.to_screen(plane.to_world(p));
// Screen-space tolerances stay the same at any zoom; only visible references wake.
let mut nearest = 8.0;
+ let mut nearest_id = None;
for (index, curve) in sk.curves.iter().enumerate() {
let Some(p) = Self::reference(sk, index).and_then(to).filter(|p| proj.rect.contains(*p)) else { continue };
let distance = cursor.distance(p);
if distance < nearest {
nearest = distance;
- self.anchor = Some(curve.id.clone());
+ nearest_id = Some(curve.id.clone());
}
}
- let Some((anchor, origin)) = self.anchor.as_deref().and_then(|id| {
- let anchor = Self::reference(sk, sk.curve_index(id)?)?;
- Some((anchor, to(anchor)?))
+ if let Some(id) = nearest_id {
+ self.remember(id);
+ }
+ let Some(anchor) = self.anchor.as_deref().and_then(|id| Self::point_of(sk, id)).or_else(|| {
+ self.anchor = self.previous.take();
+ self.anchor.as_deref().and_then(|id| Self::point_of(sk, id))
}) else {
self.anchor = None;
+ self.previous = None;
return;
};
+ if self.previous.as_deref().and_then(|id| Self::point_of(sk, id)).is_none() {
+ self.previous = None;
+ }
+ let Some(origin) = to(anchor) else { return };
if !proj.rect.contains(origin) {
return;
}
@@ -300,21 +368,27 @@ impl Tracking {
if !at.x.is_finite() || !at.y.is_finite() {
return;
}
+ // Near the crossing, both guides end on that point. Otherwise each reference keeps
+ // its own axis, and a single guide stays visual (it does not move the cursor).
+ if let Some(meet) = self.meeting(sk, plane, proj, cursor) {
+ let span = |from: Vec2| to(from).zip(to(meet)).filter(|(a, b)| a.distance(*b) > 8.0).map(|_| (from, meet));
+ self.guide = span(anchor);
+ if let Some(previous) = self.previous.as_deref().and_then(|id| Self::point_of(sk, id)) {
+ self.remembered_guide = span(previous);
+ }
+ return;
+ }
// Finite guides connect the reference to the cursor's projection onto its axis.
// No model-space length cap: the viewport clips them, as it does other sketch guides.
- let mut distance = 6.0;
- for end in [Vec2::new(at.x, anchor.y), Vec2::new(anchor.x, at.y)] {
- let Some(screen) = to(end) else { continue };
- let off_axis = cursor.distance(screen);
- if origin.distance(screen) > 8.0 && off_axis < distance {
- distance = off_axis;
- self.guide = Some((anchor, end));
- }
+ self.guide = Self::axis_guide(anchor, at, cursor, &to);
+ if let Some(previous) = self.previous.as_deref().and_then(|id| Self::point_of(sk, id)) {
+ self.remembered_guide = Self::axis_guide(previous, at, cursor, &to);
}
}
}
/// Visual H/V tracking works before a tool's first click and while simply editing a sketch.
+/// The crossing of the two remembered references is also a snap. A single guide stays visual.
/// Existing snaps, picks and constraints retain their behaviour.
pub(crate) fn track_and_show(app: &mut SolveApp, painter: &egui::Painter, proj: &Proj, cursor: Option<egui::Pos2>) {
crate::scenario::publish_count("sketch_tracking_guides", 0.0);
@@ -334,13 +408,20 @@ pub(crate) fn track_and_show(app: &mut SolveApp, painter: &egui::Painter, proj:
return;
};
tracking.update(&ss.sketch, &ss.plane, proj, cursor);
- crate::scenario::publish_count("sketch_tracking_guides", usize::from(tracking.guide.is_some()) as f64);
- if let Some((a, b)) = tracking.guide
- && let (Some(a), Some(b)) = (proj.to_screen(ss.plane.to_world(a)), proj.to_screen(ss.plane.to_world(b)))
- {
- let tk = Tokens::get();
+ let shown = tracking.guide.is_some() || tracking.remembered_guide.is_some();
+ crate::scenario::publish_count("sketch_tracking_guides", usize::from(shown) as f64);
+ let tk = Tokens::get();
+ let draw = |guide: (Vec2, Vec2)| {
+ let (Some(a), Some(b)) = (proj.to_screen(ss.plane.to_world(guide.0)), proj.to_screen(ss.plane.to_world(guide.1))) else { return None };
painter.extend(crate::viewport::dashed_line(&[a, b], painter.clip_rect(), Stroke::new(1.0, tk.rubber_band), 5.0, 4.0));
painter.circle_stroke(a, 4.0, Stroke::new(1.0, tk.rubber_band));
+ Some(b)
+ };
+ let ends = [tracking.guide.and_then(draw), tracking.remembered_guide.and_then(draw)];
+ if let (Some(a), Some(b)) = (ends[0], ends[1])
+ && a.distance(b) < 1.0
+ {
+ painter.circle_stroke(a, 4.0, Stroke::new(1.0, tk.rubber_band));
}
}
@@ -393,6 +474,55 @@ mod tests {
}
}
+ #[test]
+ fn two_recent_references_meet_and_a_third_drops_the_oldest() {
+ use solidcraft_engine::geom::Plane;
+ let mut app = SolveApp::new(Default::default(), Default::default());
+ app.cam.yaw = 0.0;
+ app.cam.pitch = std::f64::consts::FRAC_PI_2;
+ app.cam.distance = 180.0;
+ let mut sk = Sketch::new();
+ sk.add_line(Vec2::new(-30.0, 20.0), Vec2::new(30.0, 20.0), None, None, Some("top")).unwrap();
+ sk.add_line(Vec2::new(30.0, -20.0), Vec2::new(30.0, 20.0), None, None, Some("right")).unwrap();
+ sk.add_circle(Vec2::new(-10.0, 3.0), 5.0, None, Some("c")).unwrap();
+ sk.add_line(Vec2::new(50.0, -10.0), Vec2::new(50.0, 10.0), None, None, Some("far")).unwrap();
+ let proj = crate::viewport::projection(&app, egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 800.0)));
+ let to = |p: Vec2| proj.to_screen(Plane::XY.to_world(p)).unwrap();
+ let mut tracking = Tracking::default();
+ let hover = |tracking: &mut Tracking, p: Vec2| tracking.update(&sk, &Plane::XY, &proj, to(p));
+ hover(&mut tracking, Vec2::new(0.0, 20.0));
+ hover(&mut tracking, Vec2::new(30.0, 0.0));
+ let centre = Vec2::ZERO;
+ let near = to(centre) + egui::vec2(4.0, 3.0);
+ assert!(tracking.meeting(&sk, &Plane::XY, &proj, near).unwrap().dist(centre) < 1e-6);
+ tracking.update(&sk, &Plane::XY, &proj, near);
+ let (a, b) = tracking.guide.unwrap();
+ let (c, d) = tracking.remembered_guide.unwrap();
+ assert!(b.dist(centre) < 1e-6 && d.dist(centre) < 1e-6, "both guides end on the crossing");
+ assert!(a.dist(Vec2::new(30.0, 0.0)) < 1e-6 && c.dist(Vec2::new(0.0, 20.0)) < 1e-6);
+ assert!(tracking.meeting(&sk, &Plane::XY, &proj, to(centre) + egui::vec2(20.0, 0.0)).is_none());
+ // Back to the first reference: both stay, in swapped order.
+ hover(&mut tracking, Vec2::new(0.0, 20.0));
+ assert_eq!(tracking.anchor.as_deref(), Some("top"));
+ assert_eq!(tracking.previous.as_deref(), Some("right"));
+ // A circle centre and a midpoint meet the same way.
+ hover(&mut tracking, Vec2::new(-10.0, 3.0));
+ let cross = Vec2::new(0.0, 3.0);
+ assert!(tracking.meeting(&sk, &Plane::XY, &proj, to(cross)).unwrap().dist(cross) < 1e-6);
+ // A third reference drops the oldest. The far edge shares a horizontal with the right edge,
+ // so their axes do not invent the rectangle centre.
+ hover(&mut tracking, Vec2::new(30.0, 0.0));
+ hover(&mut tracking, Vec2::new(50.0, 0.0));
+ assert_eq!(tracking.anchor.as_deref(), Some("far"));
+ assert_eq!(tracking.previous.as_deref(), Some("right"));
+ assert!(tracking.meeting(&sk, &Plane::XY, &proj, to(centre)).is_none());
+ sk.curves.iter_mut().find(|c| c.id == "far").unwrap().id = "gone".into();
+ tracking.update(&sk, &Plane::XY, &proj, to(Vec2::new(40.0, 40.0)));
+ assert_eq!(tracking.anchor.as_deref(), Some("right"));
+ assert!(tracking.previous.is_none());
+ assert!(tracking.guide.is_none(), "a removed reference leaves no guide");
+ }
+
#[test]
fn parallel_and_perpendicular_from_the_previous_point() {
let s = sk();
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 81f0d7730b..e1eda41878 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -1279,6 +1279,9 @@ preference_settings! {
suppress_sketch_snap: ModifierCombo = ModifierCombo::CTRL_ALT, PAGE_SKETCH;
/// Temporary horizontal/vertical guides from hovered centres and edge midpoints.
sketch_tracking_guides: bool = true, PAGE_SKETCH;
+ /// Snap a drawing point to where the two most recent centre or midpoint guides cross.
+ /// Off: the guides stay visual and the cursor does not move (#8694).
+ sketch_recent_snap: bool = false, PAGE_SKETCH;
/// Drawing lines a point up with the sketch's points on both axes at once, keeping the
/// horizontal or vertical snap to the previous point, and the click adds the alignments
/// (#7828). Off by default: only with the previous point, one axis at a time, as before.
@@ -4971,6 +4974,7 @@ mod tests {
("sketch_state_icons", json!(false), PAGE_SKETCH),
("sketch_tracking_guides", json!(false), PAGE_SKETCH),
("sketch_align_points", json!(true), PAGE_SKETCH),
+ ("sketch_recent_snap", json!(true), PAGE_SKETCH),
("msaa", json!(8), PAGE_GRAPHICS),
("single_surface_analysis", json!(false), PAGE_GRAPHICS),
];
diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rs
index 6455f88352..ba358cb269 100644
--- a/crates/ui-egui/src/prefs/sketch.rs
+++ b/crates/ui-egui/src/prefs/sketch.rs
@@ -7,6 +7,8 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
ui_kit::settings_section(ui, "sketch", app.tr("prefs.sketching"), |ui| {
ui_kit::checkbox(ui, app.tr("prefs.sketch_tracking_guides"), &mut app.preferences.sketch_tracking_guides)
.on_hover_text(app.tr("prefs.sketch_tracking_guides_note"));
+ ui_kit::checkbox(ui, app.tr("prefs.sketch_recent_snap"), &mut app.preferences.sketch_recent_snap)
+ .on_hover_text(app.tr("prefs.sketch_recent_snap_note"));
ui_kit::checkbox(ui, app.tr("prefs.sketch_align_points"), &mut app.preferences.sketch_align_points)
.on_hover_text(app.tr("prefs.sketch_align_points_note"));
let mut auto = app.session.auto_project;
diff --git a/crates/ui-egui/src/sketch_guidance_ui_tests.rs b/crates/ui-egui/src/sketch_guidance_ui_tests.rs
index 63185e10a0..8a7f57dade 100644
--- a/crates/ui-egui/src/sketch_guidance_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_guidance_ui_tests.rs
@@ -307,6 +307,55 @@ fn centre_and_midpoint_tracking_is_visual_in_idle_and_drawing_modes() {
assert_eq!(h.app.session.undo.len(), undo);
}
+#[test]
+fn two_recent_midpoints_snap_where_their_guides_meet() {
+ use solidcraft_engine::geom::Vec2;
+ let mut h = tracking_fixture();
+ // Grid snap at this zoom already rounds a nearby cursor onto the origin. Snap off leaves
+ // the cursor where it is, so only the remembered crossing can pull it to (0, 0).
+ h.app.run("sketch.options", json!({"snap": false})).unwrap();
+ h.app.start("sketch.line");
+ // Top midpoint (0, 20) and the circle centre (-10, 3) meet at (0, 3), which is not the
+ // model origin and not a sketch point. A cursor a fraction of a millimetre away stays put
+ // until both references have been hovered.
+ let cross = Vec2::new(0.0, 3.0);
+ let near = json!({"sketch":[0.4,3.3]});
+ step(&mut h, json!({"move":{"sketch":[0,20]}}));
+ let [x, y] = h.at(&near).unwrap();
+ let pos = egui::pos2(x as f32, y as f32);
+ let proj = crate::viewport::projection(&h.app, h.app.viewport.rect.expect("viewport"));
+ let (at, _) = crate::viewport::sketch_point_at(&h.app, &proj, pos).unwrap();
+ assert!(at.dist(cross) > 0.2, "one reference does not pin both coordinates: {at:?}");
+ step(&mut h, json!({"move":{"sketch":[-10,3]}}));
+ step(&mut h, json!({"move":{"sketch":[0.4,3.3]}}));
+ let (a, b) = h.app.viewport.tracking.guide.expect("current guide");
+ let (c, d) = h.app.viewport.tracking.remembered_guide.expect("remembered guide");
+ assert!(b.dist(cross) < 1e-6 && d.dist(cross) < 1e-6, "{a:?} {b:?} {c:?} {d:?}");
+ let [x, y] = h.at(&near).unwrap();
+ let pos = egui::pos2(x as f32, y as f32);
+ let proj = crate::viewport::projection(&h.app, h.app.viewport.rect.expect("viewport"));
+ let (at, _) = crate::viewport::sketch_point_at(&h.app, &proj, pos).unwrap();
+ assert!(at.dist(cross) > 0.2, "the crossing snap is off until asked for: {at:?}");
+ h.call("ui.prefs", json!({"sketch_recent_snap": true}));
+ let (at, id) = crate::viewport::sketch_point_at(&h.app, &proj, pos).unwrap();
+ assert!(id.is_none(), "{id:?}");
+ assert!(at.dist(cross) < 1e-6, "{at:?}");
+ crate::tool_modifiers::set_target_midpoint(true);
+ let shifted = crate::viewport::sketch_point_at(&h.app, &proj, pos);
+ crate::tool_modifiers::set_target_midpoint(false);
+ let (at, _) = shifted.unwrap();
+ assert!(at.dist(cross) > 0.2, "shift midpoint mode skips the crossing: {at:?}");
+ step(&mut h, json!({"click":{"sketch":[0.4,3.3]}}));
+ let placed = h.app.tool.as_ref().unwrap().pts[0].0;
+ assert!(placed.dist(cross) < 1e-6, "{placed:?}");
+ let curves = h.app.session.world_state().sketch(h.app.session.active_sketch.unwrap()).unwrap().sketch.curves.len();
+ assert_eq!(curves, 5, "the snap adds no construction geometry");
+ h.call("ui.prefs", json!({"sketch_tracking_guides":false}));
+ h.frames(2);
+ let (at, _) = crate::viewport::sketch_point_at(&h.app, &proj, pos).unwrap();
+ assert!(at.dist(cross) > 0.2, "the preference keeps the old cursor: {at:?}");
+}
+
#[test]
fn tracking_clears_on_escape_sketch_exit_and_preference_and_respects_suppression() {
let mut h = tracking_fixture();
diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs
index d64c84aafd..fcdb97edc2 100644
--- a/crates/ui-egui/src/sketch_tools.rs
+++ b/crates/ui-egui/src/sketch_tools.rs
@@ -511,6 +511,16 @@ pub fn refine_snap(
}
}
}
+ // The two most recent midpoints or centres: snap where their axes meet. A free coordinate,
+ // so placing it adds no constraint. Off unless Sketch preferences ask for it. One reference
+ // stays a visual guide. Shift skips this.
+ if !mid_only
+ && app.preferences.sketch_recent_snap
+ && best.is_none()
+ && let Some(at) = app.viewport.tracking.meeting(sk, plane, proj, a)
+ {
+ best = Some((at.dist(lp), "+", at));
+ }
// The tool's points and kind (a click takes the tool out of the app while it runs, so the
// last hover's are kept: a rectangle's click takes no Line tool inference its hover didn't).
let (own, line_tool) = match app.tool.as_ref() {
diff --git a/docs/book/src/guide/sketching.md b/docs/book/src/guide/sketching.md
index 75783e898e..17f0176901 100644
--- a/docs/book/src/guide/sketching.md
+++ b/docs/book/src/guide/sketching.md
@@ -32,10 +32,18 @@ constraint status and **Finish Sketch** button remain visible.
Hover over a circle or arc centre, or the midpoint of a straight sketch edge, then move
horizontally or vertically to see a dotted alignment guide. The guide connects that reference
to the cursor's projection on the sketch axis, within the viewport; it disappears when you
-move away from the axis. This works while editing and before a drawing tool's first click.
-It adds no geometry or constraints. Esc, leaving the viewport, or ending the sketch clears
-the reference. Preferences › Sketch › **Center and midpoint alignment guides** turns it off;
-the configured snap-suppression modifier also hides it.
+move away from the axis. SolidCraft keeps the two most recent of these references and can
+draw both guides. One guide on its own does not move the cursor, and endpoints are ordinary
+point snaps rather than remembered references. Preferences › Sketch › **Auto snap to recent
+centers and midpoints** is off until you turn it on. With it on, a drawing tool snaps the
+cursor where the horizontal through one reference meets the vertical through the other. On a
+rectangle, the top midpoint and a side midpoint then meet at the rectangle's centre, so that
+point can be placed without a construction line. Holding Shift for midpoint-only snapping
+skips the crossing. This works while editing and before a drawing tool's first click.
+Placing the point adds no geometry or constraint of its own. Esc, leaving the viewport, or
+ending the sketch clears the references. **Center and midpoint alignment guides** turns the
+guides off, which also leaves the cursor unmoved; the configured snap-suppression modifier
+does the same for that gesture.
## Geometry
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index 524163b1a2..dd579dd77e 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -421,6 +421,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `sketch_auto_locate` (default false; with `sketch_auto_dimensions`, new shapes are also placed from the sketch origin until fully constrained, as `sketch.draw.dimensioned` with `locate`)
- `sketch_conflict_colour` (default true: while the open sketch's constraints conflict, the curves and points a failing constraint holds are drawn in the theme's `sketch_conflict` colour too, not only its glyph or dimension; false: only the glyphs and dimensions are red, in `error`, as before, #7244)
- `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned))
+- `sketch_recent_snap` (default false: while drawing, the cursor snaps where the horizontal guide of one recent circle or arc centre or straight-edge midpoint meets the vertical guide of another; a free coordinate, with no constraint and no construction geometry. Off: those guides stay visual and the cursor does not move. The references come from `sketch_tracking_guides`, #8694)
- `sketch_state_icons` (default true: a sketch's icon in History and the browser takes the colour of its solve state, `sketch` under constrained, `sketch_fixed` fully constrained, `error` while its constraints conflict, and its tooltip names the state; false: every sketch row's icon and tooltip as before, #7245)
- `sketch_tab_always` (default false: the SKETCH tab stays in the ribbon right after MODEL while no sketch is open; a tool in its CREATE or REFERENCE section then opens Create Sketch, on the selected plane or planar face or else on the plane picked next, and starts in the new sketch, #7904)
- `smooth_wheel_zoom` (default true)
@@ -464,8 +465,10 @@ the Design camera. See [the integrated Render workspace](render-workspace.md).
`ui.prefs {sketch_tracking_guides: true}` enables temporary horizontal and vertical dotted
alignment guides from hovered circle/arc centres and straight-edge midpoints (default true).
The guide spans the reference and cursor projection, including positions inside a circle.
-It is visual only: coordinates, snapping and constraints are unchanged. Set the preference
-to `false` to hide the guides.
+The two most recent references are kept, and both guides can be drawn. A single guide does
+not move the cursor. Set the preference to `false` to hide the guides. Snap suppression
+(Alt, unless rebound) does the same for that gesture. Snapping the cursor to where those
+guides cross is separate, and off unless `sketch_recent_snap` is true.
### Continuous camera motion