From 92f368f27507ca01cab63df31db01225401480ad Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 29 May 2026 23:17:58 +0300 Subject: [PATCH] =?UTF-8?q?fix(layer):=20refresh=20viewport=20after=20LAYO?= =?UTF-8?q?FF/LAYFRZ/LAYON/LAYTHW/LAYLCK=E2=80=A6=20(#42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The eight layer-state commands (LAYOFF, LAYFRZ, LAYLCK, LAYULK, LAYON, LAYTHW, LAYISO, LAYUNISO) mutated `document.layers` directly through `dl.turn_off()` / `dl.freeze()` / `dl.lock()` / … and then called `refresh_layer_panel()` — but never bumped the scene's geometry epoch. The 3D viewport caches its uploaded geometry keyed by that epoch, so visibility / freeze changes only took effect once something else triggered a re-render. Pressing Esc was the workaround because the Esc handler calls `deselect_all()`, which internally bumps geometry. The Layer Properties panel toggles already did this (their handlers in `update.rs` call `scene.bump_geometry()` after each freeze / visibility toggle), which is why the panel worked and only the command path exhibited the lag. Add `scene.bump_geometry()` after the layer mutation loop in each of the eight command branches so the viewport repaints immediately. Lock / unlock don't strictly affect rendering today but are bumped for consistency — selection / grip code may grow lock-aware later. Co-Authored-By: Claude Opus 4.7 --- src/app/commands.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/commands.rs b/src/app/commands.rs index 8bc4353d4..6f3328ca7 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -130,6 +130,7 @@ impl OpenCADStudio { dl.turn_off(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line.push_info("Layer(s) turned off."); @@ -164,6 +165,7 @@ impl OpenCADStudio { dl.freeze(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line.push_info("Layer(s) frozen."); @@ -195,6 +197,7 @@ impl OpenCADStudio { dl.lock(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line.push_info("Layer(s) locked."); @@ -233,6 +236,7 @@ impl OpenCADStudio { dl.turn_on(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line.push_info("All layers turned on."); @@ -252,6 +256,7 @@ impl OpenCADStudio { dl.thaw(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line.push_info("All layers thawed."); @@ -282,6 +287,7 @@ impl OpenCADStudio { dl.unlock(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line.push_info("Layer(s) unlocked."); @@ -315,6 +321,7 @@ impl OpenCADStudio { } } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line @@ -337,6 +344,7 @@ impl OpenCADStudio { dl.turn_on(); } } + self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; self.refresh_layer_panel(); self.command_line