forked from 1b-agent/opencadstudio-upstream
fix(hatch): keep the association when TRIM splits a boundary
Splitting a boundary object erased it and added the pieces, so the hatch lost that source and rebuilt from what was left, often the whole circle. The pieces now take over the old object's association before it is erased. Fixes #1572 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
fd01a36ad3
commit
6b5c2758e1
3 files changed
+58
-4
No files matched your search
@@ -816,6 +816,48 @@ impl Scene {
|
||||
true
|
||||
}
|
||||
|
||||
/// A boundary source split into pieces (TRIM, BREAK): every associative
|
||||
/// hatch bounded by `old` is bounded by all of `pieces` instead, so the
|
||||
/// region survives `old` being erased.
|
||||
pub(crate) fn split_hatch_source(&mut self, old: Handle, pieces: &[Handle]) {
|
||||
if pieces.is_empty() {
|
||||
return;
|
||||
}
|
||||
let dependents = self.associative_hatch_dependents(&std::iter::once(old).collect());
|
||||
if dependents.is_empty() {
|
||||
return;
|
||||
}
|
||||
for &hatch_handle in &dependents {
|
||||
if self.is_recording_undo() {
|
||||
let before = self.document.get_entity_arc(hatch_handle);
|
||||
self.record_undo_before(hatch_handle, before);
|
||||
}
|
||||
let Some(EntityType::Hatch(hatch)) = self.document.get_entity_mut(hatch_handle) else {
|
||||
continue;
|
||||
};
|
||||
for path in &mut hatch.paths {
|
||||
if !path.boundary_handles.contains(&old) {
|
||||
continue;
|
||||
}
|
||||
path.boundary_handles.retain(|source| *source != old);
|
||||
for &piece in pieces {
|
||||
if !path.boundary_handles.contains(&piece) {
|
||||
path.boundary_handles.push(piece);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.associative_hatch_source_cache.borrow_mut().take();
|
||||
let changes: Vec<_> = pieces
|
||||
.iter()
|
||||
.map(|&piece| (piece, ChangeKind::Modified))
|
||||
.collect();
|
||||
let refreshed = self.refresh_associative_hatches(&changes);
|
||||
if !refreshed.is_empty() {
|
||||
self.bump_entities(&refreshed);
|
||||
}
|
||||
}
|
||||
|
||||
fn associative_hatch_dependents(
|
||||
&self,
|
||||
changed: &rustc_hash::FxHashSet<Handle>,
|
||||
|
||||
Reference in new issue
Block a user