fix(snap): correct snap symbols + drop bogus midpoints on circles (#34)

Two bugs from #34:

1. Hovering a circle showed the Center snap as a diamond instead of
   the conventional circle outline.
2. Hovering a circle also showed Midpoint hits (triangle marker)
   even though a closed curve has no midpoint.

(2) came from a "tessellated curve" fallback in the Midpoint snap
path that produced a midpoint for every chord of the polyline
approximation. Drop that fallback — only entities with explicit
`key_vertices` (Line, LwPolyline) contribute per-segment midpoints
now. Curves that DO have a single well-defined midpoint (arcs, and
later splines) declare it explicitly via a new
`SnapHint::Midpoint`; `arc.rs` emits one at the arc-length centre.

(1) — and the broader "everything past Endpoint / Midpoint / Grid
was a diamond" inconsistency — fixed by giving every `SnapType` a
distinct marker in `SelectionCanvas::draw`:

- Center: hollow circle
- Node: circle with inscribed X
- Quadrant: diamond (unchanged)
- Intersection: X
- Apparent Intersection: X inside a square
- Insertion: two overlapping rectangles (tag glyph)
- Perpendicular: right-angle hook
- Tangent: circle with a bar across the top
- Nearest: hourglass / bowtie
- Extension: three dots
- Parallel: two parallel diagonal bars
- Endpoint / Midpoint / Grid: unchanged

Closes #34
This commit is contained in:
Hakan Seven 2026-05-29 01:39:02 +03:00
commit 0ec6d77cb1
4 changed files with 162 additions and 28 deletions

View file

@ -40,6 +40,10 @@ fn to_truck(arc: &Arc) -> TruckEntity {
};
let cv = Vec3::new(cwx as f32, cwy as f32, cwz as f32);
// Arc-length centre — one well-defined midpoint snap. Circles and
// ellipses (closed curves) deliberately don't emit this; see #34.
let mid_pt_3 = arc_pt(mid_a);
let mv = Vec3::new(mid_pt_3.x as f32, mid_pt_3.y as f32, mid_pt_3.z as f32);
let tangent = TangentGeom::Circle {
center: [cwx as f32, cwy as f32, cwz as f32],
radius: r as f32,
@ -73,7 +77,7 @@ fn to_truck(arc: &Arc) -> TruckEntity {
pts.push([pe.x + t * nx, pe.y + t * ny, pe.z + t * nz]);
return TruckEntity {
object: TruckObject::Lines(pts),
snap_pts: vec![(cv, SnapHint::Center)],
snap_pts: vec![(cv, SnapHint::Center), (mv, SnapHint::Midpoint)],
tangent_geoms: vec![tangent],
key_vertices: vec![],
fill_tris: vec![],
@ -88,7 +92,7 @@ fn to_truck(arc: &Arc) -> TruckEntity {
let edge = builder::circle_arc(&v_start, &v_end, p_mid);
TruckEntity {
object: TruckObject::Curve(edge),
snap_pts: vec![(cv, SnapHint::Center)],
snap_pts: vec![(cv, SnapHint::Center), (mv, SnapHint::Midpoint)],
tangent_geoms: vec![tangent],
key_vertices: vec![],
fill_tris: vec![],