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 <noreply@anthropic.com>
This commit is contained in:
1 parent
72d471c2e7
commit
3f060a570a
63 files changed
+514
-83
No files matched your search
@@ -1172,7 +1172,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
p
|
||||
} else if needs_entity {
|
||||
let hover_handle =
|
||||
scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds)
|
||||
scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds, self.tabs[i].scene.document.header.lineweight_display)
|
||||
.and_then(|s| Scene::handle_from_wire_name(s))
|
||||
.unwrap_or(acadrust::Handle::NULL);
|
||||
let mut p = self.tabs[i]
|
||||
@@ -1235,6 +1235,8 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
let far_pos = base + dir * far;
|
||||
let far_neg = base - dir * far;
|
||||
let guide = crate::scene::WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
@@ -1271,6 +1273,8 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
let far_pos = h.base + h.dir * far;
|
||||
let far_neg = h.base - h.dir * far;
|
||||
previews.push(crate::scene::WireModel {
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
@@ -2017,7 +2021,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let (view_rot2, eye2, all_wires2) = self.pick_view(i, &edit_cam, bounds);
|
||||
let hit = scene::pick::hit_test::click_hit(p, &all_wires2[..], view_rot2, eye2, bounds)
|
||||
let hit = scene::pick::hit_test::click_hit(p, &all_wires2[..], view_rot2, eye2, bounds, self.tabs[i].scene.document.header.lineweight_display)
|
||||
.and_then(|s| Scene::handle_from_wire_name(s));
|
||||
if let Some(handle) = hit {
|
||||
// Some commands (e.g. SS_CATCHMENT) need the entity
|
||||
@@ -2358,6 +2362,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
view_rot,
|
||||
eye,
|
||||
bounds,
|
||||
self.tabs[i].scene.document.header.lineweight_display,
|
||||
)
|
||||
.into_iter()
|
||||
.filter_map(|s| Scene::handle_from_wire_name(s))
|
||||
@@ -2373,7 +2378,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
|
||||
if !handled_by_cycling {
|
||||
let hit =
|
||||
scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds)
|
||||
scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds, self.tabs[i].scene.document.header.lineweight_display)
|
||||
.and_then(|s| Scene::handle_from_wire_name(s))
|
||||
.or_else(|| {
|
||||
scene::pick::hit_test::click_hit_hatch(
|
||||
@@ -2568,7 +2573,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
// Resolve the double-clicked object — its wire, or (for a
|
||||
// block/solid with no wire under the cursor) its shaded
|
||||
// body, which maps to the parent INSERT.
|
||||
let hit = scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds)
|
||||
let hit = scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds, self.tabs[i].scene.document.header.lineweight_display)
|
||||
.and_then(|s| Scene::handle_from_wire_name(s))
|
||||
.or_else(|| self.tabs[i].scene.solid_click_hit(p, view_rot, eye, bounds));
|
||||
if let Some(handle) = hit {
|
||||
@@ -2657,7 +2662,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
let wire_hit: Option<acadrust::Handle> = {
|
||||
let (view_rot, eye) = { let c = self.tabs[i].scene.camera.borrow(); (c.view_proj_rte(bounds), c.eye()) };
|
||||
let all_wires = self.tabs[i].scene.hit_test_wires();
|
||||
scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds)
|
||||
scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds, self.tabs[i].scene.document.header.lineweight_display)
|
||||
.and_then(|s| Scene::handle_from_wire_name(s))
|
||||
.and_then(|h| {
|
||||
if let Some(AcadEntityType::Viewport(vp)) =
|
||||
@@ -2968,7 +2973,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task<Message> {
|
||||
// Mirror the click-selection pick order so the rollover
|
||||
// highlights every selectable object: wire → hatch →
|
||||
// block-internal hatch → shaded 3D solid body.
|
||||
let hovered = scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds)
|
||||
let hovered = scene::pick::hit_test::click_hit(p, &all_wires[..], view_rot, eye, bounds, self.tabs[i].scene.document.header.lineweight_display)
|
||||
.and_then(|s| Scene::handle_from_wire_name(s))
|
||||
.or_else(|| {
|
||||
scene::pick::hit_test::click_hit_hatch(
|
||||
|
||||
Reference in new issue
Block a user