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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-05 13:10:58 +03:00
1 parent e366e47b05
commit 8ad0c8918a
1 file changed
+19 -1
+19 -1
View File
@@ -200,9 +200,27 @@ impl CadCommand for LineCommand {
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> {
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,
))