fix(properties): recolour solid meshes on a colour/layer change

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 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-21 02:12:58 +03:00
commit 5f3eaa621c
3 changed files with 10 additions and 2 deletions

View file

@ -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();
}

View file

@ -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();

View file

@ -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<Handle, [f32; 4]> = 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;