Skip to content

Commit 390ce02

Browse files
authored
Fix regression when rotating a group, resulting in an incorrect transform cage bounding box (#3184)
Revert "Reuse click target bounding boxes for document bounds" This reverts commit d9e8a71.
1 parent ab55b32 commit 390ce02

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

editor/src/messages/portfolio/document/utility_types/document_metadata.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,21 @@ impl DocumentMetadata {
154154
pub fn bounding_box_with_transform(&self, layer: LayerNodeIdentifier, transform: DAffine2) -> Option<[DVec2; 2]> {
155155
self.click_targets(layer)?
156156
.iter()
157-
.filter_map(|click_target| click_target.bounding_box_with_transform(transform))
157+
.filter_map(|click_target| match click_target.target_type() {
158+
ClickTargetType::Subpath(subpath) => subpath.bounding_box_with_transform(transform),
159+
ClickTargetType::FreePoint(_) => click_target.bounding_box_with_transform(transform),
160+
})
161+
.reduce(Quad::combine_bounds)
162+
}
163+
164+
/// Get the loose bounding box of the click target of the specified layer in the specified transform space
165+
pub fn loose_bounding_box_with_transform(&self, layer: LayerNodeIdentifier, transform: DAffine2) -> Option<[DVec2; 2]> {
166+
self.click_targets(layer)?
167+
.iter()
168+
.filter_map(|click_target| match click_target.target_type() {
169+
ClickTargetType::Subpath(subpath) => subpath.loose_bounding_box_with_transform(transform),
170+
ClickTargetType::FreePoint(_) => click_target.bounding_box_with_transform(transform),
171+
})
158172
.reduce(Quad::combine_bounds)
159173
}
160174

editor/src/messages/portfolio/document/utility_types/network_interface.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3506,7 +3506,8 @@ impl NodeNetworkInterface {
35063506
}
35073507

35083508
self.document_metadata
3509-
.click_targets(layer)
3509+
.click_targets
3510+
.get(&layer)
35103511
.map(|click| click.iter().map(ClickTarget::target_type))
35113512
.map(|target_types| Vector::from_target_types(target_types, true))
35123513
}

editor/src/messages/tool/common_functionality/snapping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl SnapManager {
333333
return;
334334
}
335335
// We use a loose bounding box here since these are potential candidates which will be filtered later anyway
336-
let Some(bounds) = document.metadata().bounding_box_with_transform(layer, DAffine2::IDENTITY) else {
336+
let Some(bounds) = document.metadata().loose_bounding_box_with_transform(layer, DAffine2::IDENTITY) else {
337337
return;
338338
};
339339
let layer_bounds = document.metadata().transform_to_document(layer) * Quad::from_box(bounds);

node-graph/gcore/src/vector/click_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct ClickTarget {
4040

4141
impl ClickTarget {
4242
pub fn new_with_subpath(subpath: Subpath<PointId>, stroke_width: f64) -> Self {
43-
let bounding_box = subpath.bounding_box();
43+
let bounding_box = subpath.loose_bounding_box();
4444
Self {
4545
target_type: ClickTargetType::Subpath(subpath),
4646
stroke_width,

0 commit comments

Comments
 (0)