fix(hatch): improve angle handling for circular arcs in tessellation

This commit is contained in:
Hakan 2026-05-12 09:41:41 +03:00
commit 468cbde5e1
2 changed files with 16 additions and 6 deletions

View file

@ -2016,14 +2016,20 @@ impl Scene {
boundary.push(to_xy(line.end.x, line.end.y)); boundary.push(to_xy(line.end.x, line.end.y));
} }
BoundaryEdge::CircularArc(arc) => { BoundaryEdge::CircularArc(arc) => {
const TAU: f64 = std::f64::consts::TAU;
let cx = arc.center.x; let cx = arc.center.x;
let cy = arc.center.y; let cy = arc.center.y;
let r = arc.radius; let r = arc.radius;
let sa = arc.start_angle; let sa = arc.start_angle;
let ea = arc.end_angle; let ea = arc.end_angle;
let end = if ea >= sa { ea } else { ea + std::f64::consts::TAU }; let ccw = arc.counter_clockwise;
let span = end - sa; let (sa, ea) = if ccw {
let segs = ((span / std::f64::consts::TAU) * 32.0).ceil().max(4.0) as u32; (sa, ea)
} else {
(TAU - sa, TAU - ea)
};
let span = ea - sa;
let segs = ((span / TAU) * 32.0).ceil().max(4.0) as u32;
for i in 0..=segs { for i in 0..=segs {
let t = sa + span * (i as f64 / segs as f64); let t = sa + span * (i as f64 / segs as f64);
boundary.push(to_xy( boundary.push(to_xy(

View file

@ -766,9 +766,13 @@ fn legacy_geometry(entity: &EntityType, world_offset: [f64; 3]) -> Geometry {
acadrust::entities::BoundaryEdge::CircularArc(arc) => { acadrust::entities::BoundaryEdge::CircularArc(arc) => {
let sa = arc.start_angle; let sa = arc.start_angle;
let ea = arc.end_angle; let ea = arc.end_angle;
let ccw_end = if ea >= sa { ea } else { ea + TAU }; let ccw = arc.counter_clockwise;
let (start_a, end_a) = (sa, ccw_end); let (sa, ea) = if ccw {
let span = end_a - start_a; (sa, ea)
} else {
(TAU - sa, TAU - ea)
};
let span = ea - sa;
let segs = ((span / TAU) * 32.0) let segs = ((span / TAU) * 32.0)
.ceil() .ceil()
.max(4.0) as u32; .max(4.0) as u32;