From d5be27f55af585c1529db39d14a55ff1f20f4e15 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 02:38:51 -0800 Subject: [PATCH] Curvature comb: a seam segment whose anchors coincide uses its handle direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit comb_closes took a straight segment's chord as its direction at the seam. When the segment's anchors sit on one point and its handle is too short to count, that chord has no length, the reversal test compared against a zero vector, and the comb closed across a seam where the path turns back. The seam check now uses the chord only when it has a length, as curvature_comb does, and falls back to the handle direction otherwise. The View › Show Curvature Comb params help and the ROADMAP line now say that the line through the tips starts again at a cusp, a straight segment included; ui_catalog.rs is regenerated. --- ROADMAP.md | 2 +- crates/geom/src/curvature.rs | 21 +++++++++++++++++++-- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 8b29a40471..2611bd4965 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -124,7 +124,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap ## Progress log -- 2026-12-03: View › Show Curvature Comb (`view.curvatureComb`) draws the curvature comb of the selected paths and compound paths: teeth along the normal as long as the curvature, and a line through their tips (#10659). Headline numbers unchanged. +- 2026-12-03: View › Show Curvature Comb (`view.curvatureComb`) draws the curvature comb of the selected paths and compound paths: teeth along the normal as long as the curvature, and a line through their tips that starts again where the path turns back on itself at a cusp, a straight segment included (#10659). Headline numbers unchanged. - 2026-12-02: The desktop Print dialog looks up installed printers in the background. Named printers become selectable after the lookup returns and the dialog applies the list. PDF File is available at once. Physical printing waits for the list to be applied, and Done can save settings while the lookup runs. The dialog shows and announces discovery and disables physical Print until the list is applied. diff --git a/crates/geom/src/curvature.rs b/crates/geom/src/curvature.rs index c95e9edf45..74c4737c9f 100644 --- a/crates/geom/src/curvature.rs +++ b/crates/geom/src/curvature.rs @@ -350,8 +350,10 @@ pub fn comb_closes(sp: &SubPath, teeth: &[CombTooth]) -> bool { match ((0..n).rev().find(|&i| !no_length(i)), (0..n).find(|&i| !no_length(i))) { (Some(into), Some(out)) => { let (a, b) = (sp.segment(into), sp.segment(out)); - let a = if sp.segment_is_line(into) { a.p3 - a.p0 } else { end_direction(a) }; - let b = if sp.segment_is_line(out) { b.p3 - b.p0 } else { start_direction(b) }; + // A straight segment's chord, as `curvature_comb` uses it, when the chord has a length. + let chord = |i: usize, c: CubicBez| Some(c.p3 - c.p0).filter(|v| sp.segment_is_line(i) && v.hypot() > 0.0); + let a = chord(into, a).unwrap_or_else(|| end_direction(a)); + let b = chord(out, b).unwrap_or_else(|| start_direction(b)); !turns_back(a, b) } _ => false, @@ -488,6 +490,21 @@ mod tests { } } + /// A segment whose anchors sit on one point and whose handle is too short to count still has + /// a direction at the seam, so a reversal there keeps the comb open. + #[test] + fn the_comb_stays_open_at_a_seam_segment_with_coincident_anchors() { + let a0 = Anchor::corner(Point::ORIGIN); + let a1 = Anchor::corner(Point::new(100.0, 0.0)); + let a2 = Anchor { h_out: Point::new(1e-12, 0.0), ..Anchor::corner(Point::ORIGIN) }; + let sp = SubPath::new(vec![a0, a1, a2], true); + assert!(sp.segment_is_line(2)); + let teeth = curvature_comb(&sp, 3, 1000.0, MAX_COMB_TEETH); + let (first, last) = (teeth.first().map(|t| t.at), teeth.last().map(|t| t.at)); + assert!(first.zip(last).is_some_and(|(f, l)| f.distance(l) < 1e-9), "the teeth meet at the seam: {teeth:?}"); + assert!(!comb_closes(&sp, &teeth), "the closing segment heads back against the first one"); + } + /// Large finite line directions still break the comb at a reversal inside the path and at its seam. #[test] fn the_comb_breaks_where_large_straight_segments_turn_back() { diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 618c9d7529..429db2126c 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -265,7 +265,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "view.curvatureComb", "Show Curvature Comb", "", - "{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on", + "{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color that starts again where the path turns back on itself at a cusp, a straight segment included; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on", ), ( "type.hiddenCharacters", diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 6f955c6dba..87302382bc 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -266,7 +266,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "view.curvatureComb", "Show Curvature Comb", "", - "{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on", + "{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color that starts again where the path turns back on itself at a cusp, a straight segment included; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on", ), ( "type.hiddenCharacters",