* claim: #5905 * Drive Joints: a Show ghost checkbox (#5905) Driving a joint draws the moved parts' old place as a translucent ghost, which gets in the way when driving joints over and over. Drive Joints has a Show ghost box under its value rows: on by default (nothing changes), off draws only the moved parts at their new place. The stopped-short warning stays. The choice is a preference (drive_joints_ghost), so it is remembered between uses; it affects Drive Joints only. The preview's Colors carry the choice (ghost), so toggling it recomputes the preview (its key hashes the colours) and world_preview leaves the ghost out. 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:
1 parent
443baa41f0
commit
1d48707d0c
8 files changed
+30
-4
No files matched your search
@@ -474,6 +474,7 @@
|
||||
"Shape": "Shape",
|
||||
"Sheet Rules": "Sheet Rules",
|
||||
"Show Agent Cursor": "Show Agent Cursor",
|
||||
"Show ghost": "Show ghost",
|
||||
"Show in folder": "Show in folder",
|
||||
"Show the pointer an AI agent moves (#35)": "Show the pointer an AI agent moves (#35)",
|
||||
"Signed axes": "Signed axes",
|
||||
|
||||
@@ -474,6 +474,7 @@
|
||||
"Shape": "形状",
|
||||
"Sheet Rules": "板金ルール",
|
||||
"Show Agent Cursor": "エージェントカーソルを表示",
|
||||
"Show ghost": "ゴーストを表示",
|
||||
"Show in folder": "フォルダに表示",
|
||||
"Show the pointer an AI agent moves (#35)": "エージェントが操作するポインターを表示 (#35)",
|
||||
"Signed axes": "符号付き座標軸",
|
||||
|
||||
@@ -474,6 +474,7 @@
|
||||
"Shape": "形状",
|
||||
"Sheet Rules": "钣金规则",
|
||||
"Show Agent Cursor": "显示代理光标",
|
||||
"Show ghost": "显示虚影",
|
||||
"Show in folder": "在文件夹中显示",
|
||||
"Show the pointer an AI agent moves (#35)": "显示 AI 代理移动的指针(#35)",
|
||||
"Signed axes": "带符号轴",
|
||||
|
||||
@@ -682,6 +682,10 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
|
||||
ui.label(RichText::new(why).color(t.warning));
|
||||
});
|
||||
}
|
||||
// The moved parts' old place, drawn as a ghost; remembered between uses (#5905).
|
||||
form_row(ui, "Show ghost", |ui| {
|
||||
crate::ui_kit::checkbox(ui, "", &mut app.preferences.drive_joints_ghost);
|
||||
});
|
||||
}
|
||||
Asm::MotionLink { a, b, ia, ib, ratio, offset } => {
|
||||
let s = &app.session;
|
||||
@@ -1062,6 +1066,9 @@ pub fn world_preview(s: &Session, cmds: &[(String, Value)], colors: Colors) -> O
|
||||
let built = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| crate::preview::build(&before, &after, colors)));
|
||||
Some(match built {
|
||||
Ok(mut b) => {
|
||||
if !colors.ghost {
|
||||
b.scene.ghost.clear();
|
||||
}
|
||||
b.bounds = after.bodies.iter().fold(Aabb3::EMPTY, |acc, x| acc.union(&x.mesh().bounds()));
|
||||
b.stopped = stopped;
|
||||
Ok(b)
|
||||
|
||||
@@ -112,6 +112,7 @@ fn joint_and_drive_preview_on_the_placed_model() {
|
||||
new_body: [2, 2, 2, 255],
|
||||
removed: [3, 3, 3, 100],
|
||||
edge: [0, 0, 0, 255],
|
||||
ghost: true,
|
||||
};
|
||||
let cmds = preview_commands(&app, &d).unwrap();
|
||||
let b = world_preview(&app.session, &cmds, colors).unwrap().unwrap();
|
||||
@@ -139,6 +140,12 @@ fn joint_and_drive_preview_on_the_placed_model() {
|
||||
assert_eq!(cmds[0].0, "joint.drive");
|
||||
let b = world_preview(&app.session, &cmds, colors).unwrap().unwrap();
|
||||
assert_eq!(b.replaced, vec!["Body2".to_string()]);
|
||||
// The moved part's old place is the ghost, unless Show ghost is off (#5905).
|
||||
assert!(!b.scene.ghost.is_empty());
|
||||
let hidden = world_preview(&app.session, &cmds, crate::preview::Colors { ghost: false, ..colors }).unwrap().unwrap();
|
||||
assert!(hidden.scene.ghost.is_empty());
|
||||
assert_eq!(hidden.replaced, b.replaced, "the moved part is still shown where it goes");
|
||||
assert_eq!(hidden.scene.tris, b.scene.tris);
|
||||
// Features preview as before while nothing is placed away from its frame, and on the
|
||||
// placed model once something is (B moved by its joint).
|
||||
assert!(world_preview(&two_boxes().session, &[("solid.extrude".into(), json!({}))], colors).is_none());
|
||||
@@ -701,6 +708,7 @@ fn drive_says_where_a_loop_stopped_it() {
|
||||
new_body: [2, 2, 2, 255],
|
||||
removed: [3, 3, 3, 100],
|
||||
edge: [0, 0, 0, 255],
|
||||
ghost: true,
|
||||
};
|
||||
let rocker = app.session.doc.assembly.joints.iter().position(|j| j.name == "Rocker").unwrap();
|
||||
let mut d = drive_joint(&app, app.session.doc.assembly.joints[rocker].id).unwrap();
|
||||
@@ -760,6 +768,7 @@ fn drive_says_when_its_joint_is_joined_to_nothing_grounded() {
|
||||
new_body: [2, 2, 2, 255],
|
||||
removed: [3, 3, 3, 100],
|
||||
edge: [0, 0, 0, 255],
|
||||
ghost: true,
|
||||
};
|
||||
let b = world_preview(&app.session, &apply_commands(&app, &d).unwrap(), colors).unwrap().unwrap();
|
||||
let why = b.stopped.as_ref().and_then(drive_stop).unwrap();
|
||||
|
||||
@@ -666,6 +666,8 @@ preference_settings! {
|
||||
/// When true: Shift+click adds without removing; Primary toggles.
|
||||
/// When false (default): Shift and Primary both toggle.
|
||||
selection_shift_add_only: bool = false, PAGE_SKETCH;
|
||||
/// Drive Joints shows the moved parts' old place as a ghost (its Show ghost box, #5905).
|
||||
drive_joints_ghost: bool = true, PAGE_DESIGN;
|
||||
/// Plugin ids turned off (Preferences › Plugins). An installed plugin whose id is absent is on.
|
||||
disabled_plugins: std::collections::BTreeSet<String> = std::collections::BTreeSet::new(), PAGE_PLUGINS;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,14 @@ pub struct Colors {
|
||||
pub new_body: [u8; 4],
|
||||
pub removed: [u8; 4],
|
||||
pub edge: [u8; 4],
|
||||
/// Whether a moved component's old place is drawn as a ghost (Drive Joints' Show ghost).
|
||||
pub ghost: bool,
|
||||
}
|
||||
|
||||
impl Colors {
|
||||
pub fn from_tokens(t: &Tokens) -> Colors {
|
||||
let c = |c: egui::Color32| c.to_srgba_unmultiplied();
|
||||
Colors { body: c(t.body), added: c(t.preview_add), new_body: c(t.preview_new), removed: c(t.preview_cut), edge: c(t.body_edge) }
|
||||
Colors { body: c(t.body), added: c(t.preview_add), new_body: c(t.preview_new), removed: c(t.preview_cut), edge: c(t.body_edge), ghost: true }
|
||||
}
|
||||
|
||||
fn for_tool(t: &Tokens, tab: &str, active: bool) -> Colors {
|
||||
@@ -320,7 +322,10 @@ pub fn update(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let colors = Colors::for_tool(&Tokens::get(), &app.ui.tab, app.tool.is_some() || app.dialog.is_some());
|
||||
let mut colors = Colors::for_tool(&Tokens::get(), &app.ui.tab, app.tool.is_some() || app.dialog.is_some());
|
||||
if app.dialog.as_ref().is_some_and(|d| matches!(d.kind, crate::dialogs::Kind::Assembly(crate::dialogs_assembly::Asm::Drive { .. }))) {
|
||||
colors.ghost = app.preferences.drive_joints_ghost;
|
||||
}
|
||||
let key = job_key(&cmds, app.session.revision, colors);
|
||||
let stream_key = stream_key(&cmds, app.session.revision, colors);
|
||||
let tool = as_new_body(&cmds).is_some();
|
||||
@@ -861,7 +866,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn colors() -> Colors {
|
||||
Colors { body: [1, 1, 1, 255], added: [2, 2, 2, 255], new_body: [4, 4, 4, 255], removed: [3, 3, 3, 100], edge: [0, 0, 0, 255] }
|
||||
Colors { body: [1, 1, 1, 255], added: [2, 2, 2, 255], new_body: [4, 4, 4, 255], removed: [3, 3, 3, 100], edge: [0, 0, 0, 255], ghost: true }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -3,7 +3,7 @@ use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
fn colors() -> Colors {
|
||||
Colors { body: [1, 1, 1, 255], added: [2, 2, 2, 255], new_body: [2, 2, 2, 255], removed: [3, 3, 3, 100], edge: [0, 0, 0, 255] }
|
||||
Colors { body: [1, 1, 1, 255], added: [2, 2, 2, 255], new_body: [2, 2, 2, 255], removed: [3, 3, 3, 100], edge: [0, 0, 0, 255], ghost: true }
|
||||
}
|
||||
|
||||
fn fixture() -> Session {
|
||||
|
||||
Reference in new issue
Block a user