From 9b45f0588d2ca71dbab0c53d4bc6d7b196b3ee2d Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Wed, 8 Jul 2026 15:56:56 +0300 Subject: [PATCH] feat(polyline): apply the full width to each side of the centreline Draw the polyline width bands with the stored width offset to each side of the centreline rather than half of it. Co-Authored-By: Claude Opus 4.8 --- src/entities/lwpolyline.rs | 8 +++++--- src/entities/polyline.rs | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/entities/lwpolyline.rs b/src/entities/lwpolyline.rs index ab1d6785b..c1c3d299e 100644 --- a/src/entities/lwpolyline.rs +++ b/src/entities/lwpolyline.rs @@ -635,7 +635,9 @@ impl crate::entities::traits::Transformable for LwPolyline { /// UTM-scale coordinates — building them in absolute f32 collapsed the band into /// a string of squares far from the origin. pub(crate) fn wide_fills(pl: &acadrust::entities::LwPolyline) -> ([f64; 2], Vec>) { - let hw_const = (pl.constant_width / 2.0) as f32; + // The stored width is applied to EACH side of the centreline (not halved), + // so `polyline_segment_fill`'s ±offset spans the full width on either side. + let hw_const = pl.constant_width as f32; let verts = &pl.vertices; let n = verts.len(); if n < 2 { @@ -648,12 +650,12 @@ pub(crate) fn wide_fills(pl: &acadrust::entities::LwPolyline) -> ([f64; 2], Vec< let v0 = &verts[i]; let v1 = &verts[(i + 1) % n]; let hw0 = if v0.start_width > 1e-9 { - v0.start_width as f32 / 2.0 + v0.start_width as f32 } else { hw_const }; let hw1 = if v0.end_width > 1e-9 { - v0.end_width as f32 / 2.0 + v0.end_width as f32 } else { hw_const }; diff --git a/src/entities/polyline.rs b/src/entities/polyline.rs index 6f526890f..a0b33cc20 100644 --- a/src/entities/polyline.rs +++ b/src/entities/polyline.rs @@ -746,7 +746,8 @@ impl Transformable for Polyline3D { /// relative to (the first vertex). See `lwpolyline::wide_fills` — offsets are /// f32 from `origin` so the band stays precise at UTM-scale coordinates. pub(crate) fn wide_fills(pl: &acadrust::entities::Polyline2D) -> ([f64; 2], Vec>) { - let hw_default = (pl.start_width.max(pl.end_width) / 2.0) as f32; + // Width is applied full to each side of the centreline (not halved). + let hw_default = pl.start_width.max(pl.end_width) as f32; let verts = &pl.vertices; let n = verts.len(); if n < 2 { @@ -759,12 +760,12 @@ pub(crate) fn wide_fills(pl: &acadrust::entities::Polyline2D) -> ([f64; 2], Vec< let v0 = &verts[i]; let v1 = &verts[(i + 1) % n]; let hw0 = if v0.start_width > 1e-9 { - v0.start_width as f32 / 2.0 + v0.start_width as f32 } else { hw_default }; let hw1 = if v0.end_width > 1e-9 { - v0.end_width as f32 / 2.0 + v0.end_width as f32 } else { hw_default };