fix(layer): refresh viewport after LAYOFF/LAYFRZ/LAYON/LAYTHW/LAYLCK… (#42)

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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.7 committed 2026-05-29 23:17:58 +03:00
1 parent 6994837d0e
commit 92f368f275
1 file changed
+8
+8
View File
@@ -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