From 5f3eaa621c364aec433bfecb3a08449f31b56ad2 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 21 Jun 2026 02:12:58 +0300 Subject: [PATCH] fix(properties): recolour solid meshes on a colour/layer change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ACIS solids bake their colour into the mesh, so a property-panel or ribbon colour (or layer) change left the solid showing its old colour — only the wires, which resolve colour at render time, updated. Run recolor_meshes (now covering block-definition meshes too) when property targets are invalidated, and route the ribbon colour change through the same path. Co-Authored-By: Claude Opus 4.8 --- src/app/properties.rs | 4 ++++ src/app/update.rs | 3 ++- src/scene/mod.rs | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/properties.rs b/src/app/properties.rs index 5afbf1762..4ec9ae7a6 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -478,6 +478,10 @@ impl OpenCADStudio { for &handle in handles { self.tabs[i].scene.mark_entity_dirty(handle); } + // Solid (ACIS) meshes bake their colour into the mesh, so a colour / + // layer change needs an explicit recolour — re-tessellating wires + // alone wouldn't update them. + self.tabs[i].scene.recolor_meshes(); self.tabs[i].scene.bump_geometry_no_blocks(); } diff --git a/src/app/update.rs b/src/app/update.rs index d2994ac51..8836f6723 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -5135,11 +5135,12 @@ impl OpenCADStudio { self.ribbon.active_color = color; } else { self.push_undo_snapshot(i, "CHPROP"); - for handle in handles { + for &handle in &handles { if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle) { crate::scene::view::dispatch::apply_color(entity, color); } } + self.invalidate_property_targets(i, &handles); self.tabs[i].dirty = true; self.ribbon.active_color = color; self.refresh_properties(); diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 5684e8cf6..7e7780a50 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1095,16 +1095,19 @@ impl Scene { pub fn recolor_meshes(&mut self) { // Cache colour lookups by handle to avoid borrowing the document // re-entrantly through `render_style` inside a `&mut self` loop. + // Covers both top-level solid meshes and block-definition meshes + // (instanced per INSERT), so a solid recolours wherever it lives. let colors: HashMap = self .meshes .keys() + .chain(self.block_meshes.keys()) .filter_map(|&h| { self.document .get_entity(h) .map(|e| (h, self.render_style(e).0)) }) .collect(); - for (h, set) in self.meshes.iter_mut() { + for (h, set) in self.meshes.iter_mut().chain(self.block_meshes.iter_mut()) { if let Some(&c) = colors.get(h) { for lod in &mut set.lods { lod.color = c;