fix: Wipeout fill color respects BACKGROUND command override

Scene now carries bg_color / paper_bg_color fields (defaults match
previous hard-coded values). synced_hatch_models() reads these instead
of hard-coded constants, so Wipeout fills correctly use the custom
background when BACKGROUND <r> <g> <b> has been set.
BACKGROUND command syncs both DocumentTab.bg_color and scene.bg_color.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-04-06 23:32:11 +03:00
commit 5d0edb3a1f
2 changed files with 13 additions and 2 deletions

View file

@ -41,8 +41,10 @@ impl H7CAD {
if args.first().map(|s| s.eq_ignore_ascii_case("RESET")).unwrap_or(false) {
if is_paper {
self.tabs[i].paper_bg_color = None;
self.tabs[i].scene.paper_bg_color = [0.22, 0.24, 0.28, 1.0];
} else {
self.tabs[i].bg_color = None;
self.tabs[i].scene.bg_color = [0.11, 0.11, 0.11, 1.0];
}
self.command_line.push_output("Background reset to default.");
} else if args.len() >= 3 {
@ -51,8 +53,10 @@ impl H7CAD {
let b = args[2].parse::<u8>().unwrap_or(0) as f32 / 255.0;
if is_paper {
self.tabs[i].paper_bg_color = Some([r, g, b, 1.0]);
self.tabs[i].scene.paper_bg_color = [r, g, b, 1.0];
} else {
self.tabs[i].bg_color = Some([r, g, b, 1.0]);
self.tabs[i].scene.bg_color = [r, g, b, 1.0];
}
self.command_line
.push_output(&format!("Background: rgb({}, {}, {})", args[0], args[1], args[2]));

View file

@ -69,6 +69,11 @@ pub struct Scene {
/// `None` = paper space editing (PSPACE). Only meaningful when
/// `current_layout != "Model"`.
pub active_viewport: Option<Handle>,
/// Custom model-space background fill color for Wipeout entities.
/// Set from the active tab's `bg_color`; defaults to dark grey.
pub bg_color: [f32; 4],
/// Custom paper-space background fill color for Wipeout entities.
pub paper_bg_color: [f32; 4],
}
impl Scene {
@ -86,6 +91,8 @@ impl Scene {
meshes: HashMap::new(),
images: HashMap::new(),
active_viewport: None,
bg_color: [0.11, 0.11, 0.11, 1.0],
paper_bg_color: [0.22, 0.24, 0.28, 1.0],
}
}
@ -1216,9 +1223,9 @@ impl Scene {
// they mask hatch fills drawn earlier in the same pass.
// Wipeout fills are appended last so they render on top of other hatches.
let bg_color: [f32; 4] = if self.current_layout == "Model" {
[0.11, 0.11, 0.11, 1.0]
self.bg_color
} else {
[0.22, 0.24, 0.28, 1.0]
self.paper_bg_color
};
for entity in self.document.entities() {
let EntityType::Wipeout(wo) = entity else { continue };