Single-hole snapping takes only shown points and checks the face once per pick (#798)
Follow-up to #718: a face place snaps only to sketch points that are shown, and the face under the cursor is looked up once per pick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17b4b9a32c
commit
dbfb689f6c
4 files changed
+582
-39
No files matched your search
@@ -829,10 +829,17 @@ fn pick_hits(app: &SolveApp, proj: &Proj, pos: Pos2, other_sketch_points: bool,
|
||||
let external_points =
|
||||
wants_points || other_sketch_points || (app.dialog.is_none() && app.tool.as_ref().is_none_or(|tool| tool.cmd == "sketch.project"));
|
||||
let point_sketches: Vec<u64> = if external_points { visible_sketches(app) } else { s.active_sketch.into_iter().collect() };
|
||||
// A face place (the Single hole's) snaps only to points their sketches show, so a nearer
|
||||
// point that isn't shown (a letter's outline) neither takes the pick nor hides a shown one.
|
||||
let snapping = app.dialog.as_ref().and_then(|d| d.active_input()).is_some_and(|i| crate::dialogs::snaps_to_points(i.accept));
|
||||
let mut best = Near::new(all);
|
||||
for ss in point_sketches.iter().filter_map(|sid| st.sketch(*sid)) {
|
||||
let sid = ss.feature;
|
||||
let shown = snapping.then(|| crate::dialogs::SnapPoints::of(&ss.sketch));
|
||||
for p in &ss.sketch.points {
|
||||
if shown.as_ref().is_some_and(|f| !f.takes(p)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(sp) = proj.to_screen(ss.plane.to_world(p.pos)) {
|
||||
let dd = sp.distance(pos) - if s.active_sketch == Some(sid) { 2.0 } else { 0.0 };
|
||||
if dd < 8.0 && best.wants(dd) {
|
||||
@@ -1215,8 +1222,8 @@ pub fn hit_sel(h: &Hit) -> Option<Sel> {
|
||||
/// dialog the first hit (sketch entities only belong to the active sketch).
|
||||
pub fn candidate(app: &SolveApp, hits: &[Hit]) -> Option<(Hit, Sel)> {
|
||||
if let Some(d) = app.dialog.as_ref().filter(|d| d.wants_picks()) {
|
||||
let face = face_under(hits);
|
||||
return hits.iter().find_map(|h| d.candidate_on(&app.session, h, face).map(|s| (h.clone(), s)));
|
||||
let snap = d.face_snap(&app.session, hits);
|
||||
return hits.iter().find_map(|h| d.candidate_on(&app.session, h, snap.as_ref()).map(|s| (h.clone(), s)));
|
||||
}
|
||||
hits.iter().filter(|h| pick_allowed(app, h)).find_map(|h| hit_candidate(app, h))
|
||||
}
|
||||
@@ -1224,17 +1231,14 @@ pub fn candidate(app: &SolveApp, hits: &[Hit]) -> Option<(Hit, Sel)> {
|
||||
/// Every hit a click could pick, in order, each with its selection (Select Other).
|
||||
pub fn candidates(app: &SolveApp, hits: &[Hit]) -> Vec<(Hit, Sel)> {
|
||||
if let Some(d) = app.dialog.as_ref().filter(|d| d.wants_picks()) {
|
||||
let face = face_under(hits);
|
||||
return hits.iter().filter_map(|h| d.candidate_on(&app.session, h, face).map(|s| (h.clone(), s))).collect();
|
||||
// The face under the cursor is looked up once for every sketch point a face place may
|
||||
// snap to, before Select Other caps its rows.
|
||||
let snap = d.face_snap(&app.session, hits);
|
||||
return hits.iter().filter_map(|h| d.candidate_on(&app.session, h, snap.as_ref()).map(|s| (h.clone(), s))).collect();
|
||||
}
|
||||
hits.iter().filter(|h| pick_allowed(app, h)).filter_map(|h| hit_candidate(app, h)).collect()
|
||||
}
|
||||
|
||||
/// The face under the cursor: the nearest face the pick ray meets (faces come nearest first).
|
||||
fn face_under(hits: &[Hit]) -> Option<&Hit> {
|
||||
hits.iter().find(|h| matches!(h, Hit::Face { .. }))
|
||||
}
|
||||
|
||||
/// What the selection filter lets a click pick with no dialog.
|
||||
fn pick_allowed(app: &SolveApp, h: &Hit) -> bool {
|
||||
let off = |k: &str| app.ui.pick_off.iter().any(|x| x == k);
|
||||
|
||||
Reference in new issue
Block a user