forked from 1b-agent/opencadstudio-upstream
fix(render): adapt mesh + hatch load colours to background
`adapt_to_bg` (pure black → white on dark bg, pure white → black on light bg) was only running through `render_style`, which the wire and per-frame hatch paths already use. The mesh population paths and the file-load hatch path went straight through `aci_to_rgba`, so: - ACIS solids / regions / bodies appeared in their raw ACI colour even when that colour was pure white on a white paper bg. - The initial hatch upload used the unadapted colour for the first frame after load (`synced_hatch_models` then re-ran adaptation per frame, so the issue cleared after one redraw — but visible). Now every mesh / hatch creation site funnels through `render_style_for` + `adapt_to_bg`: - `build_derived_caches` (load): uses the default model bg as the adaptation target. - `populate_meshes_from_document`: uses `self.render_style` so the per-frame paper / model bg selection applies. - New `Scene::recolor_meshes` rewrites every cached mesh's colour field through `render_style`; called from `BACKGROUND` (after the user changes bg) and `set_current_layout` (Model ↔ paper bg switch) so ACIS mesh colour tracks the live bg without re- tessellating ACIS geometry. Wipeout fills stay bg-coloured by design (that's their job). Raster images skip adaptation — pixel data is not entity colour.
This commit is contained in:
1 parent
e9e3bbbca1
commit
8a510c563c
2 files changed
+51
-13
No files matched your search
+7
-1
@@ -54,7 +54,12 @@ impl OpenCADStudio {
|
||||
// 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.
|
||||
// black lines invisible against the new bg. Meshes
|
||||
// bake colour into per-vertex GPU buffers at upload
|
||||
// time; `recolor_meshes` rewrites the CPU side so
|
||||
// the next epoch-driven re-upload picks up the new
|
||||
// colour.
|
||||
self.tabs[i].scene.recolor_meshes();
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
self.command_line
|
||||
.push_output("Background reset to default.");
|
||||
@@ -69,6 +74,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.recolor_meshes();
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
self.command_line.push_output(&format!(
|
||||
"Background: rgb({}, {}, {})",
|
||||
|
||||
Reference in new issue
Block a user