mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-07 07:48:12 +08:00
Fix floating point error with Poisson-disk points being sampled outside shape (#1596)
* Check opposite corner * Commets and test * Fix compiling --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
5f72a6a8a1
commit
aed30d78b8
@@ -105,7 +105,11 @@ pub fn poisson_disk_sample(
|
||||
// Intersecting the shape's border
|
||||
else {
|
||||
// The sub-square is fully inside the shape if its top-left corner is inside and its edges don't intersect the shape border
|
||||
let sub_square_fully_inside_shape = !square_edges_intersect_shape_checker(sub_square, subdivided_size) && point_in_shape_checker(sub_square);
|
||||
let sub_square_fully_inside_shape =
|
||||
!square_edges_intersect_shape_checker(sub_square, subdivided_size) && point_in_shape_checker(sub_square) && point_in_shape_checker(sub_square + subdivided_size);
|
||||
// if !square_edges_intersect_shape_checker(sub_square, subdivided_size) { assert_eq!(point_in_shape_checker(sub_square), point_in_shape_checker(sub_square + subdivided_size)); }
|
||||
// Sometimes this fails so it is necessary to also check the bottom right corner.
|
||||
|
||||
Some(ActiveSquare::new(sub_square, sub_square_fully_inside_shape))
|
||||
}
|
||||
});
|
||||
@@ -219,8 +223,9 @@ impl ActiveListLevel {
|
||||
let point_in_shape = point_in_shape_checker(corner);
|
||||
let square_edges_intersect_shape = square_edges_intersect_shape_checker(corner, square_size);
|
||||
let square_not_outside_shape = point_in_shape || square_edges_intersect_shape;
|
||||
let square_in_shape = point_in_shape && !square_edges_intersect_shape;
|
||||
|
||||
let square_in_shape = point_in_shape_checker(corner + square_size) && !square_edges_intersect_shape;
|
||||
// if !square_edges_intersect_shape { assert_eq!(point_in_shape_checker(corner), point_in_shape_checker(corner + square_size)); }
|
||||
// Sometimes this fails so it is necessary to also check the bottom right corner.
|
||||
square_not_outside_shape.then_some(ActiveSquare::new(corner, square_in_shape))
|
||||
})
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user