Viewport: hidden parts no longer draw their joint-origin triads (#11294)

* Viewport: hidden occurrences draw no joint-origin triads

A named joint origin's triad (red/green/blue axes, white dot) was drawn for every
origin, so hidden inserted hardware still showed one at its placement. It now
follows the occurrence's visibility (and its parents') and the Joints folder of
the design and of the placement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Viewport: a copy's joint-origin triad follows that copy's visibility

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SS-EN
2026-11-04 14:24:55 +00:00
committed by GitHub
parent d1927aac25
commit 73f50d7bb4
2 changed files with 52 additions and 1 deletions
+21 -1
View File
@@ -2130,11 +2130,31 @@ pub fn origins_world(s: &Session) -> Vec<(String, solidcraft_engine::doc::Mat)>
v
}
/// Is a named joint origin's triad drawn: its occurrence shown (with its parents), and the
/// Joints folder shown in the design and on that placement. Hidden hardware keeps no triad.
pub fn origin_drawn(s: &Session, name: &str) -> bool {
let Some(o) = s.doc.assembly.origins.iter().find(|o| o.name == name) else { return false };
if s.folder_hidden("c0/joints") {
return false;
}
if o.origin.occurrence == 0 {
return true;
}
let Some(occ) = s.doc.occurrences.iter().find(|x| x.id == o.origin.occurrence) else { return false };
// The origin's own placement, not its component's first one (copies hide separately).
let mut path = s.doc.first_path(occ.parent);
path.push(occ.id);
s.occurrence_visible(&path) && !s.folder_hidden(&format!("{}/joints", Session::folder_scope(&path)))
}
/// Named joint origins in the viewport: a small triad where each sits.
pub fn origins(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
let t = Tokens::get();
let len = app.cam.half_height() * 2.0 * 0.04;
for (_, m) in origins_world(&app.session) {
for (name, m) in origins_world(&app.session) {
if !origin_drawn(&app.session, &name) {
continue;
}
let at = solidcraft_engine::doc::apply_point(&m, Vec3::ZERO);
let Some(c) = proj.to_screen(at) else { continue };
for (axis, col) in [(Vec3::X, t.axis_x), (Vec3::Y, t.axis_y), (Vec3::Z, t.axis_z)] {
@@ -890,6 +890,37 @@ fn joint_origins_follow_their_component() {
assert!(at(&app).dist(Vec3::new(45.0, 10.0, 25.0)) < 1e-6, "{:?}", at(&app));
}
/// A named joint origin on a hidden occurrence draws no triad; nor does one in a hidden Joints
/// folder (the design's or the placement's). Showing it again brings the triad back.
#[test]
fn joint_origin_triads_follow_occurrence_visibility() {
let mut app = two_boxes();
app.session.execute("joint.origin", &json!({"name": "Top of B", "face": [40, 10, 10]})).unwrap();
assert!(origin_drawn(&app.session, "Top of B"));
let b = occ(&app, "B");
app.session.execute("browser.visibility", &json!({"paths": [[b]], "visible": false})).unwrap();
assert!(!origin_drawn(&app.session, "Top of B"), "a hidden occurrence still draws its origin triad");
app.session.execute("browser.visibility", &json!({"paths": [[b]], "visible": true})).unwrap();
assert!(origin_drawn(&app.session, "Top of B"));
app.session.visibility.hidden_folders.push(format!("o:{b}/joints"));
assert!(!origin_drawn(&app.session, "Top of B"), "the placement's hidden Joints folder");
app.session.visibility.hidden_folders.clear();
app.session.visibility.hidden_folders.push("c0/joints".into());
assert!(!origin_drawn(&app.session, "Top of B"), "the design's hidden Joints folder");
app.session.visibility.hidden_folders.clear();
// On a copy, the triad follows that copy, not the component's first placement.
app.session.execute("occurrence.copy", &json!({"component": "B", "translate": [0, 40, 0]})).unwrap();
app.session.execute("joint.origin", &json!({"name": "Top of copy", "face": [40, 50, 10]})).unwrap();
let copy = app.session.doc.occurrences.iter().find(|o| o.component == app.session.doc.find_component("B").unwrap() && o.id != b).unwrap().id;
assert_eq!(app.session.doc.assembly.origins.iter().find(|o| o.name == "Top of copy").unwrap().origin.occurrence, copy);
app.session.execute("browser.visibility", &json!({"paths": [[b]], "visible": false})).unwrap();
assert!(origin_drawn(&app.session, "Top of copy"), "hiding the first placement hides the copy's triad");
app.session.execute("browser.visibility", &json!({"paths": [[b]], "visible": true})).unwrap();
app.session.execute("browser.visibility", &json!({"paths": [[copy]], "visible": false})).unwrap();
assert!(!origin_drawn(&app.session, "Top of copy"), "a hidden copy still draws its origin triad");
assert!(origin_drawn(&app.session, "Top of B"));
}
/// Edit Feature on a moved component: the dialog shows the feature's picks where the
/// component is (its stored points are in the component's frame).
#[test]