mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix Poisson-disk sampling with negative space from nested subpaths (#2569)
* Fix poisson disk sampling with nested subpaths Previously all subpaths were considered independently for the poisson disk sampling evaluation. We now check agains all subpaths which might contain the point to fix shapes with holes such as fonts with letters with holes in them * Fix wasm demo * Fix counting overlapping areas twice * Rename shape variables to subpath variants
This commit is contained in:
@@ -67,7 +67,7 @@ serde = { workspace = true, optional = true, features = ["derive"] }
|
||||
ctor = { workspace = true, optional = true }
|
||||
log = { workspace = true, optional = true }
|
||||
rand_chacha = { workspace = true, optional = true }
|
||||
bezier-rs = { workspace = true, optional = true }
|
||||
bezier-rs = { workspace = true, optional = true, features = ["log"] }
|
||||
kurbo = { workspace = true, optional = true }
|
||||
base64 = { workspace = true, optional = true }
|
||||
vello = { workspace = true, optional = true }
|
||||
|
||||
@@ -1245,17 +1245,23 @@ async fn poisson_disk_points(
|
||||
if separation_disk_diameter <= 0.01 {
|
||||
return VectorDataTable::new(result);
|
||||
}
|
||||
let path_with_bounding_boxes: Vec<_> = vector_data
|
||||
.stroke_bezier_paths()
|
||||
.filter_map(|mut subpath| {
|
||||
// TODO: apply transform to points instead of modifying the paths
|
||||
subpath.apply_transform(vector_data_transform);
|
||||
subpath.loose_bounding_box().map(|bb| (subpath, bb))
|
||||
})
|
||||
.collect();
|
||||
|
||||
for mut subpath in vector_data.stroke_bezier_paths() {
|
||||
for (i, (subpath, _)) in path_with_bounding_boxes.iter().enumerate() {
|
||||
if subpath.manipulator_groups().len() < 3 {
|
||||
continue;
|
||||
}
|
||||
|
||||
subpath.apply_transform(vector_data_transform);
|
||||
|
||||
let mut previous_point_index: Option<usize> = None;
|
||||
|
||||
for point in subpath.poisson_disk_points(separation_disk_diameter, || rng.random::<f64>()) {
|
||||
for point in subpath.poisson_disk_points(separation_disk_diameter, || rng.random::<f64>(), &path_with_bounding_boxes, i) {
|
||||
let point_id = PointId::generate();
|
||||
result.point_domain.push(point_id, point);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user