forked from 1b-agent/opencadstudio-upstream
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:
1 parent
72d471c2e7
commit
3f060a570a
63 files changed
+514
-83
No files matched your search
@@ -160,6 +160,8 @@ impl CadCommand for AttdefCommand {
|
||||
// Show a small cross at the insertion point.
|
||||
let d = 0.15_f32;
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -136,6 +136,8 @@ impl CadCommand for MlineCommand {
|
||||
.collect();
|
||||
pts.push([pt.x, pt.y, pt.z]);
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -108,6 +108,8 @@ impl CadCommand for ImageCommand {
|
||||
let p3 = [origin.x, origin.y + world_height, origin.z];
|
||||
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -84,6 +84,8 @@ impl CadCommand for RayCommand {
|
||||
let dir = (pt - base).normalize_or_zero();
|
||||
let far = base + dir * DISPLAY_EXTENT;
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
@@ -177,6 +179,8 @@ impl CadCommand for XLineCommand {
|
||||
let far_pos = base + dir * DISPLAY_EXTENT;
|
||||
let far_neg = base - dir * DISPLAY_EXTENT;
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -89,6 +89,8 @@ impl CadCommand for RevCloudCommand {
|
||||
self.points[0].z as f32,
|
||||
]);
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -114,6 +114,8 @@ impl CadCommand for WipeoutCommand {
|
||||
let min = p1.min(pt);
|
||||
let max = p1.max(pt);
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
@@ -158,6 +160,8 @@ impl CadCommand for WipeoutCommand {
|
||||
self.poly_pts[0].z as f32,
|
||||
]);
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -69,6 +69,8 @@ impl CadCommand for AreaCommand {
|
||||
pts.push(f(pt));
|
||||
pts.push(f(self.points[0]));
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -63,6 +63,8 @@ impl CadCommand for DistCommand {
|
||||
let p1 = self.first?;
|
||||
// The preview wire is purely visual, so f32 vertices are fine here.
|
||||
Some(WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -67,6 +67,8 @@ impl MeasureGeomCommand {
|
||||
/// Build a cyan preview wire connecting the picked points and the cursor.
|
||||
fn preview_wire(name: &str, pts: Vec<[f32; 3]>) -> WireModel {
|
||||
WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
@@ -3059,6 +3059,8 @@ fn collect_runs(pts: &[[f64; 2]], take: &dyn Fn([f64; 2]) -> bool, out: &mut Vec
|
||||
/// Build a preview wire from a NaN-break point list.
|
||||
fn preview_wire(points: Vec<[f32; 3]>, color: [f32; 4], name: &str) -> WireModel {
|
||||
WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
|
||||
Reference in new issue
Block a user