From 8ad0c8918afe0ce06bc2f6214b4161c7e38acb80 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 5 Jul 2026 13:10:58 +0300 Subject: [PATCH] fix(draw): slide the deferred-tangent preview along the first circle While a LINE's first point is a deferred circle tangent, the rubber band stuck at the provisional pick point. Recompute the start on each mouse move as the tangent from the cursor to that circle (keeping the side the user first picked), so the tangent point on the first circle slides as the cursor moves toward the second point. Refs #274 Co-Authored-By: Claude Opus 4.8 --- src/modules/draw/draw/line.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/modules/draw/draw/line.rs b/src/modules/draw/draw/line.rs index 42951cff7..b0fd98b00 100644 --- a/src/modules/draw/draw/line.rs +++ b/src/modules/draw/draw/line.rs @@ -200,9 +200,27 @@ impl CadCommand for LineCommand { fn on_mouse_move(&mut self, pt: DVec3) -> Option { let last = *self.points.last()?; + // With a deferred first tangent, slide the rubber band's start point + // around the circle so it stays tangent toward the moving cursor, + // instead of sticking at the provisional pick point. Keep the side the + // user first picked (nearest that hit) for a stable preview. (#274) + let start = match self.deferred_tangent { + Some((TangentObject::Circle { center, radius }, hit)) => { + point_circle_tangents(pt, center, radius) + .map(|(t0, t1)| { + if (t0 - hit).length() <= (t1 - hit).length() { + t0 + } else { + t1 + } + }) + .unwrap_or(last) + } + _ => last, + }; Some(WireModel::solid_f64( "rubber_band".to_string(), - vec![[last.x, last.y, last.z], [pt.x, pt.y, pt.z]], + vec![[start.x, start.y, start.z], [pt.x, pt.y, pt.z]], WireModel::CYAN, false, ))