fix(pick): hit-test lineweight width and thickness walls

Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.

A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.

Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.

Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.

The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-17 14:58:55 +03:00
1 parent 72d471c2e7
commit 3f060a570a
63 files changed
+514 -83

No files matched your search

+17
View File
@@ -95,6 +95,19 @@ pub struct WireModel {
/// Low residual paired with [`fill_tris`] (double-single). Empty = all-zero;
/// tessellation from CAD f64 fills it so fills stay precise at UTM scale.
pub fill_tris_low: Vec<[f32; 3]>,
/// Pre-triangulated pick-only geometry: flat vertex list, 3 per triangle.
/// Hit-testing treats these as solid, the renderer never uploads them.
///
/// Non-empty only for entities extruded by a DXF thickness (code 39): the
/// swept wall between each base segment and its extruded copy. The wall is
/// drawn as its four wireframe edges (which live in [`points`]), so it has
/// no fill geometry to pick — without this the interior is a hole the
/// cursor falls through. Separate from [`fill_tris`] because that channel
/// reaches the GPU, and a wall that renders shaded would change how every
/// thickness drawing looks.
pub pick_tris: Vec<[f32; 3]>,
/// Low residual paired with [`pick_tris`] (double-single). Empty = all-zero.
pub pick_tris_low: Vec<[f32; 3]>,
/// SDF glyph quads for this entity's text (TEXT / MTEXT / dimension text /
/// block-internal text). Non-empty only when SDF text is enabled and this
/// wire carries a text run. Rides with the wire so it is cached by the
@@ -149,6 +162,8 @@ impl WireModel {
/// Create a solid wire (no dash pattern, 1px weight).
pub fn solid(name: String, points: Vec<[f32; 3]>, color: [f32; 4], selected: bool) -> Self {
Self {
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
text_verts: Vec::new(),
name,
points,
@@ -379,6 +394,8 @@ impl Default for WireModel {
vp_scissor: None,
fill_tris: Vec::new(),
fill_tris_low: Vec::new(),
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
}
}
}