mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Reintroduce improved logic for mesh interior region fill determination (#4464)
* Decide branching mesh fill insideness by winding, normalizing drawn direction at the Path node * Fix dead connector click targets by explicitly closing the kurbo ellipse port paths * Fix hole subtraction when a hole vertex is snapped exactly onto its covering contour * Classify embedded negative space by its single surrounding face so fully enclosed mesh cells still fill
This commit is contained in:
@@ -12,6 +12,10 @@ async fn path_modify(_ctx: impl Ctx, vector: Item<Vector>, modification: Item<Bo
|
||||
let mut vector = vector;
|
||||
modification.into_element().apply(vector.element_mut());
|
||||
|
||||
// Users draw subpaths in arbitrary winding directions, so normalize them here rather than
|
||||
// letting the drawn direction decide fill insideness downstream
|
||||
vector.element_mut().normalize_winding_directions();
|
||||
|
||||
// Drop the stale click-target override so hit testing uses the geometry the user is now editing
|
||||
vector.remove_attribute::<Vector>(ATTR_EDITOR_CLICK_TARGET);
|
||||
|
||||
|
||||
@@ -1435,9 +1435,11 @@ pub(crate) fn replace_with_polygons(vector: &mut Vector, polygons: Vec<Vec<DVec2
|
||||
if start == end {
|
||||
continue;
|
||||
}
|
||||
// Emit shared walls in index-canonical direction: a cycle can't be monotone in point index,
|
||||
// so no cell's boundary can wind coherently and read as deliberate negative space
|
||||
let edge = if start < end { (start, end) } else { (end, start) };
|
||||
if seen_edges.insert(edge) {
|
||||
segment_domain.push(next_segment.next_id(), start, end, BezierHandles::Linear);
|
||||
segment_domain.push(next_segment.next_id(), edge.0, edge.1, BezierHandles::Linear);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3543,10 +3545,11 @@ fn element_centroid(element: &Vector, transform: DAffine2, centroid_type: Centro
|
||||
mod test {
|
||||
use super::*;
|
||||
use core_types::Node;
|
||||
use kurbo::{CubicBez, Ellipse, Point, Rect};
|
||||
use kurbo::{CubicBez, Point, Rect};
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use vector_types::vector::algorithms::bezpath_algorithms::{TValue, trim_pathseg};
|
||||
use vector_types::vector::algorithms::shapes::ellipse_bezpath;
|
||||
use vector_types::vector::misc::pathseg_abs_diff_eq;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -3842,7 +3845,7 @@ mod test {
|
||||
async fn poisson() {
|
||||
let poisson_points = super::scatter_points(
|
||||
Footprint::default(),
|
||||
vector_item_from_bezpath(Ellipse::from_rect(Rect::new(-50., -50., 50., 50.)).to_path(DEFAULT_ACCURACY)),
|
||||
vector_item_from_bezpath(ellipse_bezpath(DVec2::splat(-50.), DVec2::splat(50.))),
|
||||
Item::new_from_element(10. * std::f64::consts::SQRT_2),
|
||||
Item::new_from_element(0),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user