fix(layers): honor layer off/freeze for block sub-entities

Block-internal entities ignored their own layer state: 2D subs were
only filtered by the invisible flag in the block-defn cache, and 3D
solids render through a separate mesh path that applied no layer filter
at all. Both now skip subs on off/frozen layers, matching top-level
entities. Caches rebuild on every toggle, so visibility updates live.

Fixes #133

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-19 19:57:19 +03:00
1 parent 0dc537b669
commit caafb9b99d
2 files changed
+58 -1

No files matched your search

+15
View File
@@ -253,6 +253,14 @@ fn collect_referenced_blocks(doc: &CadDocument) -> Vec<String> {
seen.into_iter().collect()
}
/// True when `layer` is turned off or frozen — entities on it never render.
fn layer_hidden(doc: &CadDocument, layer: &str) -> bool {
doc.layers
.get(layer)
.map(|l| l.flags.off || l.flags.frozen)
.unwrap_or(false)
}
fn build_defn(
doc: &CadDocument,
block_name: &str,
@@ -360,6 +368,13 @@ fn build_defn(
if entity.common().invisible {
continue;
}
// A sub-entity on a layer that is off or frozen must not render, same
// as a top-level entity on that layer. The defn cache is rebuilt on
// every layer off/freeze toggle (bump_geometry bumps block_epoch), so
// baking the visibility here stays in sync.
if layer_hidden(doc, &entity.common().layer) {
continue;
}
match entity {
EntityType::Block(_)
| EntityType::BlockEnd(_)