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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-17 01:49:18 +03:00
1 parent 765e6606e2
commit 48e6d0d553
42 files changed
+124 -8

No files matched your search

+1
View File
@@ -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,
+13
View File
@@ -201,6 +201,15 @@ pub fn offset_host_entity(e: &EntityType, d: f64) -> Option<EntityType> {
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> {
}
}
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;
}
+27 -8
View File
@@ -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,
+17
View File
@@ -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,
+8
View File
@@ -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(),
+9
View File
@@ -286,6 +286,15 @@ fn wire_distances(wire: &WireModel) -> (Vec<f32>, 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
+2
View File
@@ -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(),