forked from 1b-agent/opencadstudio-upstream
fix(viewport): adapt entity colours to visible bg
`model_wires_for_viewport` was tessellating with `self.bg_color` (the model bg), so model content rendered inside a paper-layout viewport adapted to a dark bg even though the transparent shader now reveals the PaperCanvas sheet behind it — white wires stayed white on a light sheet. Pass the paper bg in a paper layout. Wire cache also needed an explicit invalidation when the bg or the active layout changes; otherwise the cached, already-adapted wires were returned against the new bg unchanged. - BACKGROUND command bumps `geometry_epoch` after both branches - new `Scene::set_current_layout` setter bumps on actual change; layout switch + history restore use it
This commit is contained in:
1 parent
2b5db8501b
commit
e3c962bdd1
4 files changed
+36
-3
No files matched your search
@@ -51,6 +51,11 @@ impl OpenCADStudio {
|
||||
self.tabs[i].bg_color = None;
|
||||
self.tabs[i].scene.bg_color = [0.11, 0.11, 0.11, 1.0];
|
||||
}
|
||||
// Wire colour adaptation (`adapt_to_bg`) reads the bg
|
||||
// at tessellation time, so the cached wires need to
|
||||
// refresh — otherwise a light→dark bg flip leaves
|
||||
// black lines invisible against the new bg.
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
self.command_line
|
||||
.push_output("Background reset to default.");
|
||||
} else if args.len() >= 3 {
|
||||
@@ -64,6 +69,7 @@ impl OpenCADStudio {
|
||||
self.tabs[i].bg_color = Some([r, g, b, 1.0]);
|
||||
self.tabs[i].scene.bg_color = [r, g, b, 1.0];
|
||||
}
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
self.command_line.push_output(&format!(
|
||||
"Background: rgb({}, {}, {})",
|
||||
args[0], args[1], args[2]
|
||||
|
||||
+5
-1
@@ -32,7 +32,11 @@ impl OpenCADStudio {
|
||||
|
||||
pub(super) fn restore_history_snapshot(&mut self, i: usize, snapshot: HistorySnapshot) {
|
||||
self.tabs[i].scene.document = snapshot.document;
|
||||
self.tabs[i].scene.current_layout = snapshot.current_layout;
|
||||
self.tabs[i].scene.set_current_layout(snapshot.current_layout);
|
||||
// Force a re-tessellation: the cached wires were keyed against the
|
||||
// outgoing document / layout and would be returned unchanged
|
||||
// otherwise (`set_current_layout` only bumps on actual change).
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
self.tabs[i].scene.selected = snapshot
|
||||
.selected
|
||||
.into_iter()
|
||||
|
||||
+1
-1
@@ -3501,7 +3501,7 @@ impl OpenCADStudio {
|
||||
self.layout_rename_state = None;
|
||||
self.layout_context_menu = None;
|
||||
self.tabs[i].scene.active_viewport = None;
|
||||
self.tabs[i].scene.current_layout = name;
|
||||
self.tabs[i].scene.set_current_layout(name);
|
||||
self.tabs[i].scene.deselect_all();
|
||||
self.tabs[i].scene.restore_saved_camera();
|
||||
self.tabs[i].last_synced_camera_gen = self.tabs[i].scene.camera_generation;
|
||||
|
||||
Reference in new issue
Block a user