forked from 1b-agent/opencadstudio-upstream
fix(dim): move the baked dimension block when the dimension is transformed
A dimension's final graphics are baked into a per-instance *D block, and the render draws that block's sub-entities directly rather than the definition points. Move/rotate/scale/mirror updated the definition points but left the block sub-entities in place, so the dimension stayed drawn where it was. Apply the same transform to the dimension's *D block sub-entities. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5f1348f1b
commit
ae3b305f95
1 file changed
+32
@@ -5347,6 +5347,32 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A dimension's final geometry is baked into a per-instance `*D`
|
||||
// block, and the render draws those sub-entities directly (not the
|
||||
// definition points). Transform them with the dimension, or it would
|
||||
// stay drawn in place while only its def points move.
|
||||
let dim_block_subs: Vec<Handle> = handles
|
||||
.iter()
|
||||
.filter_map(|&h| match self.document.get_entity(h) {
|
||||
Some(EntityType::Dimension(d)) => {
|
||||
let bn = d.base().block_name.clone();
|
||||
if bn.trim().is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(bn)
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.filter_map(|bn| {
|
||||
self.document
|
||||
.block_records
|
||||
.iter()
|
||||
.find(|br| br.name.eq_ignore_ascii_case(&bn))
|
||||
.map(|br| br.entity_handles.clone())
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
for &h in handles {
|
||||
if let Some(entity) = self.document.get_entity_mut(h) {
|
||||
view::dispatch::apply_transform(entity, t);
|
||||
@@ -5384,6 +5410,12 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Move the baked dimension-block sub-entities too (collected above).
|
||||
for h in &dim_block_subs {
|
||||
if let Some(entity) = self.document.get_entity_mut(*h) {
|
||||
view::dispatch::apply_transform(entity, t);
|
||||
}
|
||||
}
|
||||
// Only the transformed entities changed (a top-level move/rotate/scale/
|
||||
// mirror never edits a block definition) — re-tessellate just those and
|
||||
// keep the block cache + every other entity's memoized wires.
|
||||
|
||||
Reference in new issue
Block a user