Skip to content

Commit 59d1439

Browse files
indierustyKeavon
authored andcommitted
fix insideness checking
1 parent c5991c6 commit 59d1439

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

node-graph/gcore/src/vector/algorithms/bezpath_algorithms.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -617,28 +617,19 @@ pub fn bezpath_is_inside_bezpath(bezpath1: &BezPath, bezpath2: &BezPath, accurac
617617
let inner_bbox = bezpath1.bounding_box();
618618
let outer_bbox = bezpath2.bounding_box();
619619

620-
// Eliminate bezpath1 if its bounding box is not completely inside the bezpath2's bounding box.
621-
// Reasoning:
622-
// If the inner bezpath bounding box is larger than the outer bezpath bounding box in any direction
623-
// then the inner bezpath is intersecting with or outside the outer bezpath.
624-
if !outer_bbox.contains_rect(inner_bbox) {
625-
return false;
626-
}
627-
628-
// Eliminate bezpath1 if any of its anchor points are outside the bezpath2.
629-
if !bezpath1.elements().iter().filter_map(|el| el.end_point()).all(|point| bezpath2.contains(point)) {
620+
// Eliminate 'bezpath1' if its bounding box is completely outside the bezpath2's bounding box
621+
if !outer_bbox.contains_rect(inner_bbox) && outer_bbox.intersect(inner_bbox).is_zero_area() {
630622
return false;
631623
}
632624

633625
// Eliminate this subpath if it intersects with the other subpath.
634-
if !bezpath_intersections(bezpath1, bezpath2, accuracy, minimum_separation).is_empty() {
626+
if !bezpath_intersections(bezpath1, &bezpath2, accuracy, minimum_separation).is_empty() {
635627
return false;
636628
}
637629

638630
// At this point:
639-
// (1) This subpath's bounding box is inside the other subpath's bounding box,
640-
// (2) Its anchors are inside the other subpath, and
641-
// (3) It is not intersecting with the other subpath.
631+
// (1) The 'bezpath1' bounding box either intersect or is inside the 'bezpath2's bounding box,
632+
// (2) The 'bezpath1' is not intersecting with the 'bezpath2'.
642633
// Hence, this subpath is completely inside the given other subpath.
643634
true
644635
}

0 commit comments

Comments
 (0)