Skip to content

Commit 11314e6

Browse files
committed
fix tranforming segments
1 parent eef780a commit 11314e6

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

node-graph/gcore/src/vector/misc.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,6 @@ pub fn pathseg_points_vec(segment: PathSeg) -> Vec<Point> {
220220
}
221221
}
222222

223-
pub fn transform_pathseg(segment: PathSeg, transform: impl Fn(DVec2) -> DVec2) -> PathSeg {
224-
let transform = |point: Point| dvec2_to_point(transform(point_to_dvec2(point)));
225-
match segment {
226-
PathSeg::Line(line) => PathSeg::Line(Line::new(transform(line.p0), transform(line.p1))),
227-
PathSeg::Quad(quad_bez) => PathSeg::Quad(QuadBez::new(transform(quad_bez.p0), transform(quad_bez.p1), transform(quad_bez.p2))),
228-
PathSeg::Cubic(cubic_bez) => PathSeg::Cubic(CubicBez::new(transform(cubic_bez.p0), transform(cubic_bez.p0), transform(cubic_bez.p0), transform(cubic_bez.p0))),
229-
}
230-
}
231-
232223
/// Returns true if the corresponding points of the two [`PathSeg`]s are within the provided absolute value difference from each other.
233224
pub fn pathseg_abs_diff_eq(seg1: PathSeg, seg2: PathSeg, max_abs_diff: f64) -> bool {
234225
let seg1 = if is_linear(seg1) { PathSeg::Line(Line::new(seg1.start(), seg1.end())) } else { seg1 };

node-graph/gpath-bool/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ use glam::{DAffine2, DVec2};
33
use graphene_core::subpath::{ManipulatorGroup, Subpath};
44
use graphene_core::table::{Table, TableRow, TableRowRef};
55
use graphene_core::vector::algorithms::merge_by_distance::MergeByDistanceExt;
6-
use graphene_core::vector::misc::{point_to_dvec2, transform_pathseg};
6+
use graphene_core::vector::misc::point_to_dvec2;
77
use graphene_core::vector::style::Fill;
88
use graphene_core::vector::{PointId, Vector};
99
use graphene_core::{Color, Ctx, Graphic};
10-
use kurbo::{ParamCurve, Point};
10+
use kurbo::{Affine, ParamCurve, Point};
1111
pub use path_bool as path_bool_lib;
1212
use path_bool::{FillRule, PathBooleanOperation};
13-
use std::ops::Mul;
1413

1514
// TODO: Fix boolean ops to work by removing .transform() and .one_instnace_*() calls,
1615
// TODO: since before we used a Vec of single-row tables and now we use a single table
@@ -300,8 +299,7 @@ fn to_path_segments(path: &mut Vec<path_bool::PathSegment>, subpath: &Subpath<Po
300299
let mut global_start = None;
301300
let mut global_end = Point::ZERO;
302301
for bezier in subpath.iter() {
303-
const EPS: f64 = 1e-8;
304-
let transformed = transform_pathseg(bezier, |pos| transform.transform_point2(pos).mul(EPS.recip()).round().mul(EPS));
302+
let transformed = Affine::new(transform.to_cols_array()) * bezier;
305303
let start = transformed.start();
306304
let end = transformed.end();
307305
if global_start.is_none() {

0 commit comments

Comments
 (0)