fix: hide block definition entities from viewport
Block-definition geometry (entities stored inside named blocks) was leaking into the viewport when DXF files omit the owner-handle group code (330) on block-content entities. The fix tightens `belongs_to_visible_block`: when `owner_handle` is null, the current layout block-record's `entity_handles` list is used as the authoritative allow-list before falling back to the older "not-in-any-other-block" heuristic. This ensures block definitions are never rendered directly, only when referenced via an INSERT. Bumps version to 0.1.4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e2f5715de8
commit
62fbaf5da4
3 changed files with 13 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -4,7 +4,7 @@ version = 4
|
|||
|
||||
[[package]]
|
||||
name = "H7CAD"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"acadrust",
|
||||
"bytemuck",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "H7CAD"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
|
|
|
|||
|
|
@ -429,11 +429,6 @@ impl Scene {
|
|||
}
|
||||
|
||||
/// Decide whether an entity should be drawn as direct content of `block_handle`.
|
||||
///
|
||||
/// Normal case: entity.owner_handle equals the active layout/model block.
|
||||
/// Fallback: if owner is null, allow it only when the handle is not listed
|
||||
/// under any other block record. This prevents block-definition geometry
|
||||
/// from leaking into the viewport when malformed files omit owner handles.
|
||||
fn belongs_to_visible_block(
|
||||
&self,
|
||||
entity_handle: Handle,
|
||||
|
|
@ -450,6 +445,17 @@ impl Scene {
|
|||
return false;
|
||||
}
|
||||
|
||||
// owner_handle is null (common in DXF files that omit group code 330).
|
||||
// Use the current layout's entity_handles as the authoritative list when
|
||||
// available — this prevents block-definition geometry from leaking into
|
||||
// the viewport even when owner handles are missing.
|
||||
if let Some(br) = self.document.block_records.iter().find(|br| br.handle == block_handle) {
|
||||
if !br.entity_handles.is_empty() {
|
||||
return br.entity_handles.contains(&entity_handle);
|
||||
}
|
||||
}
|
||||
|
||||
// entity_handles not populated: fall back to "not listed in any other block".
|
||||
!self
|
||||
.document
|
||||
.block_records
|
||||
|
|
|
|||
Loading…
Reference in a new issue