From 48e6d0d553ea26eff89c79254b5039deb6eed9d5 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 17 Jul 2026 01:49:18 +0300 Subject: [PATCH] feat(dgn-ls): dash walls from start + fix wall connector and cap identity DET pipe walls now carry the stroke pattern (dash_from_start), which tiles from each wall's own start vertex and skips the A-type end alignment that was force-lighting a solid dash under the end symbol. Two rendering fixes on top: - Dedup the host polyline's vertices before offsetting the walls. Some DGN pipe polylines carry trailing duplicate end vertices; a zero-length segment gave offset_xy a degenerate normal, leaving that vertex un-offset and folding the wall down to the centre line. The two walls' fold segments met at the centre and drew a spurious line linking them. - Re-key the symbol (end circle / half-ellipse) wires to the host handle so the whole pipe picks and selects as one entity instead of the symbols acting as separate phantom entities. Co-Authored-By: Claude Opus 4.8 --- src/app/update/viewport.rs | 2 ++ src/entities/dimension.rs | 5 ++++ src/entities/leader.rs | 2 ++ src/entities/multileader.rs | 4 +++ src/entities/table.rs | 1 + src/modules/annotate/aligned_dim.rs | 2 ++ src/modules/annotate/angular_dim.rs | 1 + src/modules/annotate/diameter_dim.rs | 1 + src/modules/annotate/dim_baseline.rs | 1 + src/modules/annotate/dim_continue.rs | 1 + src/modules/annotate/dimjogline.rs | 1 + src/modules/annotate/dimtedit.rs | 1 + src/modules/annotate/leader_cmd.rs | 1 + src/modules/annotate/linear_dim.rs | 1 + src/modules/annotate/mleader_cmd.rs | 1 + src/modules/annotate/mleader_edit.rs | 1 + src/modules/annotate/ordinate_dim.rs | 1 + src/modules/annotate/qdim.rs | 1 + src/modules/annotate/radius_dim.rs | 1 + src/modules/annotate/table_cmd.rs | 1 + src/modules/annotate/tolerance_cmd.rs | 1 + src/modules/draw/draw/attdef.rs | 1 + src/modules/draw/draw/mline.rs | 1 + src/modules/draw/draw/raster_image.rs | 1 + src/modules/draw/draw/ray.rs | 2 ++ src/modules/draw/draw/revcloud.rs | 1 + src/modules/draw/draw/wipeout.rs | 2 ++ src/modules/draw/inquiry/area.rs | 1 + src/modules/draw/inquiry/dist.rs | 1 + src/modules/draw/inquiry/measuregeom.rs | 1 + src/modules/draw/modify/trim.rs | 1 + src/modules/layout/mview.rs | 1 + src/modules/model/primitive_cmd.rs | 1 + src/modules/view/plot_window.rs | 1 + src/modules/view/zoom_window.rs | 1 + src/scene/cache/block_cache.rs | 1 + src/scene/convert/dgn_linestyle.rs | 13 +++++++++ src/scene/convert/tess.rs | 35 +++++++++++++++++++------ src/scene/convert/tessellate.rs | 17 ++++++++++++ src/scene/model/wire_model.rs | 8 ++++++ src/scene/pipeline/wire_gpu.rs | 9 +++++++ src/scene/text/complex_lt.rs | 2 ++ 42 files changed, 124 insertions(+), 8 deletions(-) diff --git a/src/app/update/viewport.rs b/src/app/update/viewport.rs index 33e8002f1..f3fa2fb65 100644 --- a/src/app/update/viewport.rs +++ b/src/app/update/viewport.rs @@ -1235,6 +1235,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task { let far_pos = base + dir * far; let far_neg = base - dir * far; let guide = crate::scene::WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "__polar_guide__".into(), points: vec![ @@ -1269,6 +1270,7 @@ pub(super) fn on_tick(&mut self, t: Instant) -> Task { let far_pos = h.base + h.dir * far; let far_neg = h.base - h.dir * far; previews.push(crate::scene::WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "__otrack_guide__".into(), points: vec![ diff --git a/src/entities/dimension.rs b/src/entities/dimension.rs index 7d790690e..f7b2240de 100644 --- a/src/entities/dimension.rs +++ b/src/entities/dimension.rs @@ -1352,6 +1352,7 @@ fn tessellate_dimension_inner( let (ext1, ext2) = split_ext_lines(&geom.ext_lines); if !ext1.is_empty() { wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: ext1, @@ -1374,6 +1375,7 @@ fn tessellate_dimension_inner( } if !ext2.is_empty() { wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: ext2, @@ -1396,6 +1398,7 @@ fn tessellate_dimension_inner( } } else { wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: geom.ext_lines, @@ -1419,6 +1422,7 @@ fn tessellate_dimension_inner( } wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: geom.dim_lines, @@ -1458,6 +1462,7 @@ fn tessellate_dimension_inner( aci_to_rgba(&c) }; wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: vec![], diff --git a/src/entities/leader.rs b/src/entities/leader.rs index c3e684480..6a4af99d1 100644 --- a/src/entities/leader.rs +++ b/src/entities/leader.rs @@ -589,6 +589,7 @@ impl LeaderTess for Leader { if verts.len() < 2 { return WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points: vec![], @@ -691,6 +692,7 @@ impl LeaderTess for Leader { } WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points, diff --git a/src/entities/multileader.rs b/src/entities/multileader.rs index 5f17d8e47..bbe95346e 100644 --- a/src/entities/multileader.rs +++ b/src/entities/multileader.rs @@ -1399,6 +1399,7 @@ impl MultiLeaderTess for MultiLeader { // WireModels so the renderer respects per-piece coloring. let mut wires: Vec = Vec::new(); wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points, @@ -1682,6 +1683,7 @@ impl MultiLeaderTess for MultiLeader { xy = xy.max(y); } wires.push(WireModel { + dash_from_start: false, text_verts: sdf_verts, name: name.clone(), points: vec![], @@ -1745,6 +1747,7 @@ impl MultiLeaderTess for MultiLeader { wcs_corners[3], ]; wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: vec![], @@ -1776,6 +1779,7 @@ impl MultiLeaderTess for MultiLeader { wcs_corners[0], ]; wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points: frame_points, diff --git a/src/entities/table.rs b/src/entities/table.rs index a527fdb77..7bba123e4 100644 --- a/src/entities/table.rs +++ b/src/entities/table.rs @@ -748,6 +748,7 @@ pub fn tessellate_table( let mk = |color: [f32; 4], points: Vec<[f32; 3]>, fill_tris: Vec<[f32; 3]>, lw: f32| -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points, diff --git a/src/modules/annotate/aligned_dim.rs b/src/modules/annotate/aligned_dim.rs index ae813a356..bd154cd08 100644 --- a/src/modules/annotate/aligned_dim.rs +++ b/src/modules/annotate/aligned_dim.rs @@ -186,6 +186,7 @@ impl CadCommand for AlignedDimensionCommand { let p1 = p1.as_vec3(); let p2 = p2.as_vec3(); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimaligned_preview".into(), points: vec![[p1.x, p1.y, p1.z], [p2.x, p2.y, p2.z]], @@ -233,6 +234,7 @@ fn preview_aligned(p1: DVec3, p2: DVec3, dim_pt: DVec3) -> WireModel { let d1 = d1.as_vec3(); let d2 = d2.as_vec3(); WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimaligned_preview".into(), points: vec![ diff --git a/src/modules/annotate/angular_dim.rs b/src/modules/annotate/angular_dim.rs index 9f35f5eeb..4410ff0fb 100644 --- a/src/modules/annotate/angular_dim.rs +++ b/src/modules/annotate/angular_dim.rs @@ -130,6 +130,7 @@ fn v3(pt: DVec3) -> Vector3 { fn preview_wire(points: Vec) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimangular_preview".to_string(), points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(), diff --git a/src/modules/annotate/diameter_dim.rs b/src/modules/annotate/diameter_dim.rs index 5e86d9396..6362e4ce3 100644 --- a/src/modules/annotate/diameter_dim.rs +++ b/src/modules/annotate/diameter_dim.rs @@ -180,6 +180,7 @@ fn v3(p: DVec3) -> Vector3 { fn preview_line(a: Vec3, b: Vec3) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimdia_preview".into(), points: vec![[a.x, a.y, a.z], [b.x, b.y, b.z]], diff --git a/src/modules/annotate/dim_baseline.rs b/src/modules/annotate/dim_baseline.rs index 9607f7ceb..75678310b 100644 --- a/src/modules/annotate/dim_baseline.rs +++ b/src/modules/annotate/dim_baseline.rs @@ -179,6 +179,7 @@ impl CadCommand for DimBaselineCommand { let dim_line_pt2 = dim_line_pt2.as_vec3(); let pt = pt.as_vec3(); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimbase_preview".into(), points: vec![ diff --git a/src/modules/annotate/dim_continue.rs b/src/modules/annotate/dim_continue.rs index 5cd5bf50b..bdb197b42 100644 --- a/src/modules/annotate/dim_continue.rs +++ b/src/modules/annotate/dim_continue.rs @@ -159,6 +159,7 @@ impl CadCommand for DimContinueCommand { let dim_line_pt = p1 + perp * (dim_line_perp - p1.dot(perp)); let dim_line_pt2 = pt + perp * (dim_line_perp - pt.dot(perp)); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimcont_preview".into(), points: vec![ diff --git a/src/modules/annotate/dimjogline.rs b/src/modules/annotate/dimjogline.rs index 4540e24f7..75cc87e5c 100644 --- a/src/modules/annotate/dimjogline.rs +++ b/src/modules/annotate/dimjogline.rs @@ -85,6 +85,7 @@ impl CadCommand for DimJogLineCommand { } let d = 0.3_f32; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimjog_preview".into(), // Jog zigzag in the XY drawing plane (Z is elevation, ~0). The old diff --git a/src/modules/annotate/dimtedit.rs b/src/modules/annotate/dimtedit.rs index d7ffcaa67..d5774b6eb 100644 --- a/src/modules/annotate/dimtedit.rs +++ b/src/modules/annotate/dimtedit.rs @@ -100,6 +100,7 @@ impl CadCommand for DimTeditCommand { } let d = 0.2_f32; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimtedit_preview".into(), // Marker box in the XY drawing plane (Z is elevation, ~0). The old diff --git a/src/modules/annotate/leader_cmd.rs b/src/modules/annotate/leader_cmd.rs index 69eb43572..a7301a8e3 100644 --- a/src/modules/annotate/leader_cmd.rs +++ b/src/modules/annotate/leader_cmd.rs @@ -163,6 +163,7 @@ fn preview_wire(pts: &[Vec3]) -> WireModel { points.push([w2.x, w2.y, w2.z]); } WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "leader_preview".into(), points, diff --git a/src/modules/annotate/linear_dim.rs b/src/modules/annotate/linear_dim.rs index 8f4a2c5c4..ff63ecdea 100644 --- a/src/modules/annotate/linear_dim.rs +++ b/src/modules/annotate/linear_dim.rs @@ -218,6 +218,7 @@ fn v3(pt: DVec3) -> Vector3 { fn preview_wire(points: Vec) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimlinear_preview".to_string(), points: points diff --git a/src/modules/annotate/mleader_cmd.rs b/src/modules/annotate/mleader_cmd.rs index 0ebe2e8dd..a39f81f00 100644 --- a/src/modules/annotate/mleader_cmd.rs +++ b/src/modules/annotate/mleader_cmd.rs @@ -150,6 +150,7 @@ fn preview_wire(pts: &[Vec3]) -> WireModel { points.push([w2.x, w2.y, w2.z]); } WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "mleader_preview".into(), points, diff --git a/src/modules/annotate/mleader_edit.rs b/src/modules/annotate/mleader_edit.rs index cccc0df1f..1d724afe8 100644 --- a/src/modules/annotate/mleader_edit.rs +++ b/src/modules/annotate/mleader_edit.rs @@ -458,6 +458,7 @@ impl CadCommand for MLeaderCollectCommand { fn preview_wire(pts: &[Vec3]) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "mleader_edit_preview".into(), points: pts.iter().map(|p| [p.x, p.y, p.z]).collect(), diff --git a/src/modules/annotate/ordinate_dim.rs b/src/modules/annotate/ordinate_dim.rs index e982c5b8d..bb845bcfe 100644 --- a/src/modules/annotate/ordinate_dim.rs +++ b/src/modules/annotate/ordinate_dim.rs @@ -121,6 +121,7 @@ fn ordinate_elbow(feature: DVec3, leader: DVec3, is_x: bool) -> DVec3 { fn preview_wire(points: Vec) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimordinate_preview".into(), points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(), diff --git a/src/modules/annotate/qdim.rs b/src/modules/annotate/qdim.rs index 432ad4c70..ec216fab5 100644 --- a/src/modules/annotate/qdim.rs +++ b/src/modules/annotate/qdim.rs @@ -90,6 +90,7 @@ impl CadCommand for QdimCommand { } let d = 0.5_f32; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "qdim_preview".into(), points: vec![[pt.x - d * 3.0, pt.y, pt.z], [pt.x + d * 3.0, pt.y, pt.z]], diff --git a/src/modules/annotate/radius_dim.rs b/src/modules/annotate/radius_dim.rs index 86937ec5b..8ac7e5b09 100644 --- a/src/modules/annotate/radius_dim.rs +++ b/src/modules/annotate/radius_dim.rs @@ -185,6 +185,7 @@ fn v3(pt: DVec3) -> Vector3 { fn preview_wire(points: Vec) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dimradius_preview".to_string(), points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(), diff --git a/src/modules/annotate/table_cmd.rs b/src/modules/annotate/table_cmd.rs index 30b72d99d..5bab500e3 100644 --- a/src/modules/annotate/table_cmd.rs +++ b/src/modules/annotate/table_cmd.rs @@ -139,6 +139,7 @@ impl CadCommand for TableCommand { let y = pt.y; let z = pt.z; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "table_preview".into(), points: vec![ diff --git a/src/modules/annotate/tolerance_cmd.rs b/src/modules/annotate/tolerance_cmd.rs index 8a8edb5cd..61f80ee74 100644 --- a/src/modules/annotate/tolerance_cmd.rs +++ b/src/modules/annotate/tolerance_cmd.rs @@ -84,6 +84,7 @@ impl CadCommand for ToleranceCommand { } let d = 0.15_f32; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "tolerance_preview".into(), points: vec![ diff --git a/src/modules/draw/draw/attdef.rs b/src/modules/draw/draw/attdef.rs index fc032b327..5d5fdb08d 100644 --- a/src/modules/draw/draw/attdef.rs +++ b/src/modules/draw/draw/attdef.rs @@ -160,6 +160,7 @@ impl CadCommand for AttdefCommand { // Show a small cross at the insertion point. let d = 0.15_f32; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "attdef_preview".into(), points: vec![ diff --git a/src/modules/draw/draw/mline.rs b/src/modules/draw/draw/mline.rs index 5e5757311..2ae5090ac 100644 --- a/src/modules/draw/draw/mline.rs +++ b/src/modules/draw/draw/mline.rs @@ -136,6 +136,7 @@ impl CadCommand for MlineCommand { .collect(); pts.push([pt.x, pt.y, pt.z]); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "mline_preview".into(), points: pts, diff --git a/src/modules/draw/draw/raster_image.rs b/src/modules/draw/draw/raster_image.rs index 2d7d25f72..7f2c27b3b 100644 --- a/src/modules/draw/draw/raster_image.rs +++ b/src/modules/draw/draw/raster_image.rs @@ -108,6 +108,7 @@ impl CadCommand for ImageCommand { let p3 = [origin.x, origin.y + world_height, origin.z]; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "image_preview".into(), points: vec![p0, p1, p2, p3, p0], diff --git a/src/modules/draw/draw/ray.rs b/src/modules/draw/draw/ray.rs index 1e57b2f0d..e1d9de5cf 100644 --- a/src/modules/draw/draw/ray.rs +++ b/src/modules/draw/draw/ray.rs @@ -84,6 +84,7 @@ impl CadCommand for RayCommand { let dir = (pt - base).normalize_or_zero(); let far = base + dir * DISPLAY_EXTENT; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "ray_preview".into(), points: vec![[base.x, base.y, base.z], [far.x, far.y, far.z]], @@ -175,6 +176,7 @@ impl CadCommand for XLineCommand { let far_pos = base + dir * DISPLAY_EXTENT; let far_neg = base - dir * DISPLAY_EXTENT; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "xline_preview".into(), points: vec![ diff --git a/src/modules/draw/draw/revcloud.rs b/src/modules/draw/draw/revcloud.rs index 156ad81a5..66ac436cd 100644 --- a/src/modules/draw/draw/revcloud.rs +++ b/src/modules/draw/draw/revcloud.rs @@ -89,6 +89,7 @@ impl CadCommand for RevCloudCommand { self.points[0].z as f32, ]); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "revcloud_preview".into(), points: preview_pts, diff --git a/src/modules/draw/draw/wipeout.rs b/src/modules/draw/draw/wipeout.rs index bc300e094..ea4289beb 100644 --- a/src/modules/draw/draw/wipeout.rs +++ b/src/modules/draw/draw/wipeout.rs @@ -114,6 +114,7 @@ impl CadCommand for WipeoutCommand { let min = p1.min(pt); let max = p1.max(pt); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "wipeout_preview".into(), points: vec![ @@ -156,6 +157,7 @@ impl CadCommand for WipeoutCommand { self.poly_pts[0].z as f32, ]); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "wipeout_poly_preview".into(), points: pts, diff --git a/src/modules/draw/inquiry/area.rs b/src/modules/draw/inquiry/area.rs index 34d8e32ee..099d41e0e 100644 --- a/src/modules/draw/inquiry/area.rs +++ b/src/modules/draw/inquiry/area.rs @@ -69,6 +69,7 @@ impl CadCommand for AreaCommand { pts.push(f(pt)); pts.push(f(self.points[0])); Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "area_preview".into(), points: pts, diff --git a/src/modules/draw/inquiry/dist.rs b/src/modules/draw/inquiry/dist.rs index 7fa2faeb4..bde5cf274 100644 --- a/src/modules/draw/inquiry/dist.rs +++ b/src/modules/draw/inquiry/dist.rs @@ -63,6 +63,7 @@ impl CadCommand for DistCommand { let p1 = self.first?; // The preview wire is purely visual, so f32 vertices are fine here. Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "dist_preview".into(), points: vec![ diff --git a/src/modules/draw/inquiry/measuregeom.rs b/src/modules/draw/inquiry/measuregeom.rs index 05a22943a..cebbc3e87 100644 --- a/src/modules/draw/inquiry/measuregeom.rs +++ b/src/modules/draw/inquiry/measuregeom.rs @@ -67,6 +67,7 @@ impl MeasureGeomCommand { /// Build a cyan preview wire connecting the picked points and the cursor. fn preview_wire(name: &str, pts: Vec<[f32; 3]>) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.to_string(), points: pts, diff --git a/src/modules/draw/modify/trim.rs b/src/modules/draw/modify/trim.rs index 7bd065978..77959c53b 100644 --- a/src/modules/draw/modify/trim.rs +++ b/src/modules/draw/modify/trim.rs @@ -3059,6 +3059,7 @@ fn collect_runs(pts: &[[f64; 2]], take: &dyn Fn([f64; 2]) -> bool, out: &mut Vec /// Build a preview wire from a NaN-break point list. fn preview_wire(points: Vec<[f32; 3]>, color: [f32; 4], name: &str) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.into(), points, diff --git a/src/modules/layout/mview.rs b/src/modules/layout/mview.rs index 41c89fa40..df338e1ee 100644 --- a/src/modules/layout/mview.rs +++ b/src/modules/layout/mview.rs @@ -81,6 +81,7 @@ impl CadCommand for MviewCommand { let pt = pt.as_vec3(); let c1 = self.corner1?; Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "mview_preview".to_string(), points: vec![ diff --git a/src/modules/model/primitive_cmd.rs b/src/modules/model/primitive_cmd.rs index 86f0400f7..589808d03 100644 --- a/src/modules/model/primitive_cmd.rs +++ b/src/modules/model/primitive_cmd.rs @@ -305,6 +305,7 @@ inventory::submit!(crate::command::CommandRegistration { fn wire(name: &str, points: Vec<[f32; 3]>) -> WireModel { WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.into(), points, diff --git a/src/modules/view/plot_window.rs b/src/modules/view/plot_window.rs index 6ed9ab723..bb036799a 100644 --- a/src/modules/view/plot_window.rs +++ b/src/modules/view/plot_window.rs @@ -48,6 +48,7 @@ impl CadCommand for PlotWindowCommand { let p1 = self.p1?.as_vec3(); // Draw the selection rectangle. Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "plotwindow_preview".into(), points: vec![ diff --git a/src/modules/view/zoom_window.rs b/src/modules/view/zoom_window.rs index 27590cc61..a71ac431c 100644 --- a/src/modules/view/zoom_window.rs +++ b/src/modules/view/zoom_window.rs @@ -65,6 +65,7 @@ impl CadCommand for ZoomWindowCommand { let max = p1.max(pt); // Draw a rectangle preview Some(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: "zoom_window_preview".into(), points: vec![ diff --git a/src/scene/cache/block_cache.rs b/src/scene/cache/block_cache.rs index 26e170dba..258064e77 100644 --- a/src/scene/cache/block_cache.rs +++ b/src/scene/cache/block_cache.rs @@ -826,6 +826,7 @@ impl Batches { // the cached defn. let color = crate::scene::view::render::adapt_to_bg(b.color, bg_color); WireModel { + dash_from_start: false, text_verts: b.text_verts, name: name.to_string(), points: b.points, diff --git a/src/scene/convert/dgn_linestyle.rs b/src/scene/convert/dgn_linestyle.rs index d77b16648..3f1ae0cd0 100644 --- a/src/scene/convert/dgn_linestyle.rs +++ b/src/scene/convert/dgn_linestyle.rs @@ -201,6 +201,15 @@ pub fn offset_host_entity(e: &EntityType, d: f64) -> Option { let mut clone = e.clone(); match &mut clone { EntityType::LwPolyline(p) => { + // Drop consecutive duplicate vertices first. A zero-length segment + // gives `offset_xy` a degenerate normal, which leaves that vertex + // un-offset — folding the wall down to the centre line and drawing a + // spurious segment that visually links the two walls. (Some DGN pipe + // polylines carry trailing duplicate end vertices.) + p.vertices.dedup_by(|a, b| { + (a.location.x - b.location.x).abs() < 1e-9 + && (a.location.y - b.location.y).abs() < 1e-9 + }); if p.vertices.len() < 2 { return None; } @@ -215,6 +224,10 @@ pub fn offset_host_entity(e: &EntityType, d: f64) -> Option { } } EntityType::Polyline2D(p) => { + p.vertices.dedup_by(|a, b| { + (a.location.x - b.location.x).abs() < 1e-9 + && (a.location.y - b.location.y).abs() < 1e-9 + }); if p.vertices.len() < 2 { return None; } diff --git a/src/scene/convert/tess.rs b/src/scene/convert/tess.rs index bef941704..25a55d23b 100644 --- a/src/scene/convert/tess.rs +++ b/src/scene/convert/tess.rs @@ -481,6 +481,7 @@ pub(crate) fn tessellate_entity( (ins.insert_point.z) as f32, ); let marker = WireModel { + dash_from_start: false, text_verts: Vec::new(), name: h.value().to_string(), points: vec![], @@ -729,16 +730,21 @@ pub(crate) fn tessellate_entity( .find(|s| *s > 1e-9) .unwrap_or(1.0); let f = radius / scale; + // The wall stroke's dash length (`wall_dashes[0]`) renders as an + // equal dash/gap: dash-first `[+dash, -dash]`. Combined with the + // `dash_from_start` flag set below, each wall tiles from its own + // start vertex with a dash, no A-type end alignment. let native = convert::dgn_linestyle::wall_dashes(document, lt_name); - let (wall_pat, wall_pat_len) = if f > 1e-9 && native.len() >= 2 { - let mut pat = [0.0_f32; 8]; - let mut plen = 0.0_f32; - for (i, &d) in native.iter().take(8).enumerate() { - let v = (d * f) as f32; - pat[i] = if i % 2 == 0 { v } else { -v }; - plen += v; + let (wall_pat, wall_pat_len) = if f > 1e-9 && !native.is_empty() { + let dash = (native[0] * f) as f32; + if dash > 1e-6 { + let mut pat = [0.0_f32; 8]; + pat[0] = dash; + pat[1] = -dash; + (pat, 2.0 * dash) + } else { + ([0.0_f32; 8], 0.0) } - (pat, plen) } else { ([0.0_f32; 8], 0.0) }; @@ -767,6 +773,10 @@ pub(crate) fn tessellate_entity( if wall_pat_len > 1e-6 { x.pattern = wall_pat; x.pattern_length = wall_pat_len; + // DGN: draw the dash from this wall's own start + // vertex, no A-type end forcing. Each wall is a + // separate wire, so the two tile independently. + x.dash_from_start = true; } } rails.append(&mut w); @@ -790,7 +800,14 @@ pub(crate) fn tessellate_entity( world_per_pixel, bg_color, ); + // The symbol wires come back named after the anonymous block's + // internal entity handle. Re-key them to the host entity (like the + // walls above) so the whole DET pipe picks/selects as one entity + // instead of the symbols acting as separate phantom entities. + let host_name = h.value().to_string(); for w in &mut wires { + w.name = host_name.clone(); + w.aci = aci; w.aabb = aabb; } bases.extend(wires); @@ -838,6 +855,7 @@ fn lod_stub_wire( // LOD boundary. #19. let stored_color = if selected { WireModel::SELECTED } else { color }; WireModel { + dash_from_start: false, text_verts: Vec::new(), name, // Diagonal of the entity's 3D AABB so depth tests against @@ -901,6 +919,7 @@ fn lod_stub_wire_3d( } let stored_color = if selected { WireModel::SELECTED } else { color }; WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points, diff --git a/src/scene/convert/tessellate.rs b/src/scene/convert/tessellate.rs index 0483970a4..020941214 100644 --- a/src/scene/convert/tessellate.rs +++ b/src/scene/convert/tessellate.rs @@ -313,6 +313,7 @@ pub fn tessellate( ) }; elem_wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: pts, @@ -587,6 +588,7 @@ pub fn tessellate( ftl.push(lo); } wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: vec![], @@ -620,6 +622,7 @@ pub fn tessellate( fpl.push(lo); } wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: fp, @@ -660,6 +663,7 @@ pub fn tessellate( low.push(ll); } wires.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: pts, @@ -681,6 +685,7 @@ pub fn tessellate( }); } wires.push(WireModel { + dash_from_start: false, text_verts: sdf_verts, name, points: Vec::new(), @@ -732,6 +737,7 @@ pub fn tessellate( (Vec::new(), Vec::new(), Vec::new()) }; out.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: bin.pts, @@ -765,6 +771,7 @@ pub fn tessellate( (Vec::new(), Vec::new(), Vec::new()) }; out.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: Vec::new(), @@ -795,6 +802,7 @@ pub fn tessellate( // are empty → the early-return path above). if !sdf_verts.is_empty() { out.push(WireModel { + dash_from_start: false, text_verts: sdf_verts, name: name.clone(), points: Vec::new(), @@ -818,6 +826,7 @@ pub fn tessellate( if out.is_empty() { out.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points: Vec::new(), @@ -863,6 +872,7 @@ pub fn tessellate( .map(|[kx, ky, kz]| [kx, ky, kz]) .collect(); return vec![WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points: vec![ @@ -907,6 +917,7 @@ pub fn tessellate( .map(|[x, y, z]| [x, y, z]) .collect(); return vec![WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points, @@ -940,6 +951,7 @@ pub fn tessellate( .map(|[x, y, z]| [x, y, z]) .collect(); return vec![WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points, @@ -992,6 +1004,7 @@ pub fn tessellate( (Vec::new(), Vec::new(), Vec::new()) }; out.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: local_pts, @@ -1024,6 +1037,7 @@ pub fn tessellate( (Vec::new(), Vec::new(), Vec::new()) }; out.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.clone(), points: Vec::new(), @@ -1047,6 +1061,7 @@ pub fn tessellate( if out.is_empty() { out.push(WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points: Vec::new(), @@ -1080,6 +1095,7 @@ pub fn tessellate( .map(|[x, y, z]| [x, y, z]) .collect(); return vec![WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points: local_pts, @@ -1144,6 +1160,7 @@ pub fn tessellate( let snap_pts: Vec<(glam::DVec3, SnapHint)> = snap_pts.into_iter().map(|(p, h)| (p.as_dvec3(), h)).collect(); vec![WireModel { + dash_from_start: false, text_verts: Vec::new(), name, points, diff --git a/src/scene/model/wire_model.rs b/src/scene/model/wire_model.rs index 09b641ae0..3030cecca 100644 --- a/src/scene/model/wire_model.rs +++ b/src/scene/model/wire_model.rs @@ -73,6 +73,12 @@ pub struct WireModel { /// When false the linetype pattern restarts at each NaN-separated segment /// (DXF PLINEGEN=0). When true the pattern runs continuously (PLINEGEN=1). pub plinegen: bool, + /// DGN line-style marker. When false (every standard linetype) the dash + /// pattern uses the normal phase: A-type end alignment for dash-first + /// patterns, else centred. When true (DGN pipe walls) the pattern is drawn + /// from the START vertex with continuous phase and no A-type end forcing — + /// DGN line styles are not end-aligned. + pub dash_from_start: bool, /// Paper-space bounding box [x0, y0, x1, y1] for GPU scissor clipping. /// Set only for viewport-projected wires in paper-space layouts. pub vp_scissor: Option<[f32; 4]>, @@ -151,6 +157,7 @@ impl WireModel { key_vertices: vec![], aabb: Self::UNBOUNDED_AABB, plinegen: true, + dash_from_start: false, vp_scissor: None, fill_tris: vec![], fill_tris_low: Vec::new(), @@ -359,6 +366,7 @@ impl Default for WireModel { key_vertices: Vec::new(), aabb: Self::UNBOUNDED_AABB, plinegen: true, + dash_from_start: false, vp_scissor: None, fill_tris: Vec::new(), fill_tris_low: Vec::new(), diff --git a/src/scene/pipeline/wire_gpu.rs b/src/scene/pipeline/wire_gpu.rs index 37a145704..cfa3ac4c1 100644 --- a/src/scene/pipeline/wire_gpu.rs +++ b/src/scene/pipeline/wire_gpu.rs @@ -286,6 +286,15 @@ fn wire_distances(wire: &WireModel) -> (Vec, f32, f32) { return (dists, 0.0, 0.0); } + // DGN line styles draw the pattern from the START vertex with continuous + // phase and are NOT end-aligned. The raw arc-length distances already put + // dist 0 at the first vertex, so a dash-first pattern begins a dash exactly + // there. Return before the A-type / centring logic that standard linetypes + // use (see `WireModel::dash_from_start`). + if wire.dash_from_start { + return (dists, 0.0, 0.0); + } + // Align only a proper alternating pattern that BEGINS with a dash followed // by a gap — every standard linetype does (DASHED/DASHDOT/CENTER/HIDDEN/…). // Gap-first, dot-first, single-element, or consecutive-dash patterns keep diff --git a/src/scene/text/complex_lt.rs b/src/scene/text/complex_lt.rs index f05934486..d59e05360 100644 --- a/src/scene/text/complex_lt.rs +++ b/src/scene/text/complex_lt.rs @@ -221,6 +221,7 @@ pub fn apply_along( .into_iter() .filter(|s| s.len() >= 2) .map(|pts| WireModel { + dash_from_start: false, text_verts: Vec::new(), name: name.to_string(), points: pts, @@ -256,6 +257,7 @@ pub fn apply_along( xy = xy.max(y); } out.push(WireModel { + dash_from_start: false, text_verts, name: name.to_string(), points: Vec::new(),