Skip to content

Commit 742d0e8

Browse files
authored
Implement combined parameter logic in box_warp function
Added logic to compute combined bounding box for vectors.
1 parent 9d80eb4 commit 742d0e8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

node-graph/nodes/vector/src/vector_nodes.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,22 @@ async fn box_warp(_: impl Ctx, content: Table<Vector>, #[expose] rectangle: Tabl
789789
let Some((target, target_transform)) = rectangle.get(0).map(|rect| (rect.element, rect.transform)) else {
790790
return content;
791791
};
792+
793+
// Compute combined bounding box if needed
794+
let combined_bbox = if combined {
795+
content.iter().fold(None, |acc: Option<[DVec2; 2]>, row| {
796+
let bbox = row.element.bounding_box_with_transform(row.transform);
797+
match (acc, bbox) {
798+
(None, Some(bbox)) => Some(bbox),
799+
(Some([min, max]), Some([bbox_min, bbox_max])) => {
800+
Some([min.min(bbox_min), max.max(bbox_max)])
801+
}
802+
(acc, None) => acc,
803+
}
804+
})
805+
} else {
806+
None
807+
};
792808

793809
content
794810
.into_iter()
@@ -797,7 +813,7 @@ async fn box_warp(_: impl Ctx, content: Table<Vector>, #[expose] rectangle: Tabl
797813
let vector = row.element;
798814

799815
// Get the bounding box of the source vector geometry
800-
let source_bbox = vector.bounding_box_with_transform(transform).unwrap_or([DVec2::ZERO, DVec2::ONE]);
816+
let source_bbox = combined_bbox.unwrap_or_else(|| vector.bounding_box_with_transform(transform).unwrap_or([DVec2::ZERO, DVec2::ONE]));
801817

802818
// Extract first 4 points from target shape to form the quadrilateral
803819
// Apply the target's transform to get points in world space

0 commit comments

Comments
 (0)