fix(render): flag 2D overlay fills so they show in every view mode

A SOLID's filled quad and a dimension/MultiLeader text background are flat 2-D
overlays that should draw in wireframe and shaded alike, but face3d_gpu
classified fills by `!fill_tris_low.is_empty()` — and a 2-D fill at UTM scale
carries a double-single low residual for precision just like a real 3-D mesh
face. So the arrowhead fill and the "5;8" cyan text background were routed to
the 3-D buffer and only appeared in shaded mode, vanishing back to nothing on
return to wireframe.

WireModel now carries an explicit `fill_is_3d`: true only for a real surface
(PolyfaceMesh / PolygonMesh face, set in the tessellator), false for every flat
overlay fill. face3d_gpu classifies on the flag, so 2-D fills stay in the
always-visible buffer while keeping their low residual (and UTM precision).

Verified on budweiser: the `_BoxFilled` arrow SOLID and the dim '5;8' MTEXT
background both tessellate with fill_is_3d = false.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-07-18 15:15:24 +03:00
commit 50f6196594
41 changed files with 94 additions and 6 deletions

View file

@ -842,6 +842,7 @@ impl Batches {
// the cached defn.
let color = crate::scene::view::render::adapt_to_bg(b.color, bg_color);
WireModel {
fill_is_3d: false,
pick_tris: b.pick_tris,
pick_tris_low: b.pick_tris_low,
dash_from_start: false,

View file

@ -555,6 +555,7 @@ pub(crate) fn tessellate_entity(
(ins.insert_point.z) as f32,
);
let marker = WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -934,6 +935,7 @@ fn lod_stub_wire(
// LOD boundary. #19.
let stored_color = if selected { WireModel::SELECTED } else { color };
WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -1020,6 +1022,7 @@ fn lod_stub_wire_3d(
}
let stored_color = if selected { WireModel::SELECTED } else { color };
WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,

View file

@ -370,6 +370,7 @@ pub fn tessellate(
None
};
elem_wires.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
// MLINE dashes: A-type aligned, but the end-dash length is
@ -652,6 +653,7 @@ pub fn tessellate(
ftl.push(lo);
}
wires.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -689,6 +691,7 @@ pub fn tessellate(
fpl.push(lo);
}
wires.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -733,6 +736,7 @@ pub fn tessellate(
low.push(ll);
}
wires.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -758,6 +762,7 @@ pub fn tessellate(
});
}
wires.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -813,6 +818,7 @@ pub fn tessellate(
(Vec::new(), Vec::new(), Vec::new())
};
out.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -850,6 +856,7 @@ pub fn tessellate(
(Vec::new(), Vec::new(), Vec::new())
};
out.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -884,6 +891,7 @@ pub fn tessellate(
// are empty → the early-return path above).
if !sdf_verts.is_empty() {
out.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -911,6 +919,7 @@ pub fn tessellate(
if out.is_empty() {
out.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -960,6 +969,7 @@ pub fn tessellate(
.map(|[kx, ky, kz]| [kx, ky, kz])
.collect();
return vec![WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -1008,6 +1018,7 @@ pub fn tessellate(
.map(|[x, y, z]| [x, y, z])
.collect();
return vec![WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -1047,6 +1058,7 @@ pub fn tessellate(
// A wide polyline arrives here: its band is pick geometry.
let (pick_tris, pick_tris_low) = points_to_ds(te.pick_tris);
return vec![WireModel {
fill_is_3d: false,
pick_tris,
pick_tris_low,
dash_from_start: false,
@ -1088,6 +1100,14 @@ pub fn tessellate(
.map(|[x, y, z]| [x, y, z])
.collect();
let (fill_tris, fill_tris_low) = points_to_ds(te.fill_tris);
// Only a real 3-D mesh surface (PolyfaceMesh / PolygonMesh) fill
// renders shaded-only with hidden-surface depth; every other
// `fill_tris` here (a SOLID's filled quad — e.g. a `_BoxFilled`
// arrowhead) is a flat 2-D overlay visible in every view mode.
let fill_is_3d = matches!(
entity,
EntityType::PolyfaceMesh(_) | EntityType::PolygonMesh(_)
);
// Thickness walls ride on the wire that carries their edges, not
// on a wire of their own: they are pick geometry for that entity,
// and `fill_tris` below deliberately splits off into a fill-only
@ -1108,6 +1128,7 @@ pub fn tessellate(
(Vec::new(), Vec::new(), Vec::new())
};
out.push(WireModel {
fill_is_3d: false,
pick_tris,
pick_tris_low,
dash_from_start: false,
@ -1166,11 +1187,13 @@ pub fn tessellate(
vp_scissor: None,
fill_tris,
fill_tris_low,
fill_is_3d,
});
}
if out.is_empty() {
out.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -1210,6 +1233,7 @@ pub fn tessellate(
// A wide polyline with PLINEGEN=0 arrives here.
let (pick_tris, pick_tris_low) = points_to_ds(te.pick_tris);
return vec![WireModel {
fill_is_3d: false,
pick_tris,
pick_tris_low,
dash_from_start: false,
@ -1278,6 +1302,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 {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,

View file

@ -122,6 +122,13 @@ pub struct WireModel {
/// exactly like `points` — no separate collector pass. The renderer
/// gathers these across all wires into the text vertex buffer.
pub text_verts: Vec<crate::scene::pipeline::text_gpu::TextVertex>,
/// `true` when [`fill_tris`] is a real 3-D surface (PolyfaceMesh /
/// PolygonMesh face) that must render with hidden-surface depth and only in
/// shaded modes. `false` for a flat 2-D overlay fill (SOLID arrowhead,
/// dimension / MultiLeader text background, greek-LOD text) that draws in
/// every view mode. The render pass can't infer this from `fill_tris_low`
/// alone — a 2-D fill at UTM scale carries a low residual too.
pub fill_is_3d: bool,
}
impl WireModel {
@ -169,6 +176,7 @@ impl WireModel {
/// Create a solid wire (no dash pattern, 1px weight).
pub fn solid(name: String, points: Vec<[f32; 3]>, color: [f32; 4], selected: bool) -> Self {
Self {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
text_verts: Vec::new(),
@ -401,6 +409,7 @@ impl Default for WireModel {
vp_scissor: None,
fill_tris: Vec::new(),
fill_tris_low: Vec::new(),
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
}

View file

@ -186,12 +186,13 @@ impl Face3DGpu {
// (text greek, MultiLeader / dimension backgrounds) deliberately
// leave `fill_tris_low` empty and order by draw rank instead.
//
// NOTE: classifying by `!points.is_empty()` is wrong here — the
// tessellator emits a mesh's edges and its fill as *separate*
// WireModels (points-only vs fill-only), so the fill model has no
// points and was being misrouted to the 2-D (draw-order-biased)
// buffer, which drew meshes in front of solids.
let is_3d_mesh_face = !wire.fill_tris_low.is_empty();
// NOTE: classifying by `!points.is_empty()` is wrong (a mesh emits
// its edges and its fill as *separate* WireModels), and so is
// `!fill_tris_low.is_empty()` — a 2-D overlay fill (SOLID arrowhead,
// dimension text background) at UTM scale carries a low residual
// too, and would be misrouted to the 3-D buffer where it only shows
// in shaded modes. The tessellator flags real surfaces explicitly.
let is_3d_mesh_face = wire.fill_is_3d;
let [r, g, b, a] = wire.color;
if is_3d_mesh_face {
if !keep_3d_mesh_fills {

View file

@ -305,6 +305,7 @@ pub fn apply_along(
.into_iter()
.filter(|s| s.len() >= 2)
.map(|pts| WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,
@ -344,6 +345,7 @@ pub fn apply_along(
xy = xy.max(y);
}
out.push(WireModel {
fill_is_3d: false,
pick_tris: Vec::new(),
pick_tris_low: Vec::new(),
dash_from_start: false,