feat(render): solid fill for PolyfaceMesh and PolygonMesh entities

PolyfaceMesh and PolygonMesh were wireframe-only. They now render with
the same flat-color solid fill as Face3D entities.

- Add fill_tris: Vec<[f32;3]> to TruckEntity and WireModel
- PolyfaceMesh: fan-triangulate each face into fill_tris
- PolygonMesh: triangulate each grid quad into fill_tris
- tessellate.rs Lines branch: apply world_offset to fill_tris
- Face3DGpu::from_wires: collect fill_tris from all wires in addition
  to Face3D key_vertices quads
- upload_face3d: pass all_wires so fill_tris are batched into one draw call
This commit is contained in:
Hakan Seven committed 2026-05-06 23:24:26 +03:00
1 parent ca9ec8f47d
commit 048bb41aef
61 files changed
+151 -21

No files matched your search

+2
View File
@@ -87,6 +87,7 @@ fn to_truck(arc: &Arc) -> TruckEntity {
snap_pts: vec![(cv, SnapHint::Center)],
tangent_geoms: vec![tangent],
key_vertices: vec![],
fill_tris: vec![],
};
}
@@ -101,6 +102,7 @@ fn to_truck(arc: &Arc) -> TruckEntity {
snap_pts: vec![(cv, SnapHint::Center)],
tangent_geoms: vec![tangent],
key_vertices: vec![],
fill_tris: vec![],
}
}
+2
View File
@@ -42,6 +42,7 @@ impl TruckConvertible for AttributeDefinition {
snap_pts: vec![(snap_pt, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
})
}
}
@@ -146,6 +147,7 @@ impl TruckConvertible for AttributeEntity {
snap_pts: vec![(snap_pt, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
})
}
}
+2
View File
@@ -91,6 +91,7 @@ fn to_truck(circle: &Circle) -> TruckEntity {
snap_pts,
tangent_geoms: vec![tangent],
key_vertices: vec![],
fill_tris: vec![],
};
}
@@ -104,6 +105,7 @@ fn to_truck(circle: &Circle) -> TruckEntity {
snap_pts,
tangent_geoms: vec![tangent],
key_vertices: vec![],
fill_tris: vec![],
}
}
+2
View File
@@ -102,6 +102,7 @@ fn to_truck(ell: &Ellipse) -> TruckEntity {
snap_pts,
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
}
} else {
let n = 32usize;
@@ -133,6 +134,7 @@ fn to_truck(ell: &Ellipse) -> TruckEntity {
snap_pts: vec![(center_v3, SnapHint::Center)],
tangent_geoms: vec![],
key_vertices,
fill_tris: vec![],
}
}
}
+1
View File
@@ -64,6 +64,7 @@ fn to_truck(leader: &Leader) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: tangents,
key_vertices: key_verts,
fill_tris: vec![],
}
}
+2
View File
@@ -50,6 +50,7 @@ fn to_truck(line: &Line) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![tangent],
key_vertices: kv,
fill_tris: vec![],
};
}
@@ -61,6 +62,7 @@ fn to_truck(line: &Line) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![tangent],
key_vertices: kv,
fill_tris: vec![],
}
}
+4 -1
View File
@@ -106,7 +106,7 @@ fn thick_segments(
pts.push(off(last));
}
}
TruckEntity { object: TruckObject::Lines(pts), snap_pts: vec![], tangent_geoms: tangents, key_vertices: key_verts }
TruckEntity { object: TruckObject::Lines(pts), snap_pts: vec![], tangent_geoms: tangents, key_vertices: key_verts, fill_tris: vec![] }
}
fn to_truck(pline: &LwPolyline) -> TruckEntity {
@@ -117,6 +117,7 @@ fn to_truck(pline: &LwPolyline) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
};
}
@@ -237,6 +238,7 @@ fn to_truck(pline: &LwPolyline) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: tgs,
key_vertices: kv,
fill_tris: vec![],
};
}
@@ -305,6 +307,7 @@ fn to_truck(pline: &LwPolyline) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: tangents,
key_vertices: key_verts,
fill_tris: vec![],
}
}
+27 -3
View File
@@ -64,6 +64,7 @@ impl TruckConvertible for Face3D {
],
tangent_geoms: vec![],
key_vertices: vec![p0, p1, p2, p3],
fill_tris: vec![],
})
}
}
@@ -182,9 +183,9 @@ impl TruckConvertible for PolygonMesh {
};
let mut pts: Vec<[f32; 3]> = Vec::new();
let mut fill_tris: Vec<[f32; 3]> = Vec::new();
// Rows (M direction).
let m_end = if closed_m { m } else { m - 1 };
for i in 0..m {
pts.push([f32::NAN; 3]);
for j in 0..n {
@@ -196,7 +197,6 @@ impl TruckConvertible for PolygonMesh {
}
// Columns (N direction).
let n_end = if closed_n { n } else { n - 1 };
for j in 0..n {
pts.push([f32::NAN; 3]);
for i in 0..m {
@@ -206,13 +206,26 @@ impl TruckConvertible for PolygonMesh {
pts.push(pt(0, j));
}
}
let _ = (m_end, n_end); // suppress warnings
// Fill: triangulate each grid quad (two triangles per cell).
let mi = if closed_m { m } else { m - 1 };
let ni = if closed_n { n } else { n - 1 };
for i in 0..mi {
for j in 0..ni {
let p00 = pt(i, j);
let p10 = pt((i + 1) % m, j);
let p01 = pt(i, (j + 1) % n);
let p11 = pt((i + 1) % m, (j + 1) % n);
fill_tris.extend_from_slice(&[p00, p10, p11, p00, p11, p01]);
}
}
Some(TruckEntity {
object: TruckObject::Lines(pts),
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris,
})
}
}
@@ -294,6 +307,7 @@ impl TruckConvertible for PolyfaceMesh {
};
let mut pts: Vec<[f32; 3]> = Vec::new();
let mut fill_tris: Vec<[f32; 3]> = Vec::new();
for face in &self.faces {
// Indices: 0 means unused. Negative = invisible edge (still render for wireframe).
@@ -313,6 +327,15 @@ impl TruckConvertible for PolyfaceMesh {
}
// Close the face polygon.
pts.push(verts[0]);
// Fan-triangulate the face for solid fill.
if verts.len() >= 3 {
for i in 1..(verts.len() - 1) {
fill_tris.push(verts[0]);
fill_tris.push(verts[i]);
fill_tris.push(verts[i + 1]);
}
}
}
Some(TruckEntity {
@@ -320,6 +343,7 @@ impl TruckConvertible for PolyfaceMesh {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris,
})
}
}
+1
View File
@@ -109,6 +109,7 @@ impl TruckConvertible for MLine {
snap_pts,
tangent_geoms: vec![],
key_vertices: key_verts,
fill_tris: vec![],
})
}
}
+1
View File
@@ -177,6 +177,7 @@ fn to_truck(t: &MText, document: &acadrust::CadDocument) -> TruckEntity {
snap_pts: vec![(insertion, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
}
}
+1
View File
@@ -156,6 +156,7 @@ fn to_truck(ml: &MultiLeader, document: &acadrust::CadDocument) -> Option<TruckE
snap_pts,
tangent_geoms: tangents,
key_vertices: key_verts,
fill_tris: vec![],
})
}
+2
View File
@@ -22,6 +22,7 @@ fn to_truck(ole: &Ole2Frame) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
};
}
@@ -42,6 +43,7 @@ fn to_truck(ole: &Ole2Frame) -> TruckEntity {
snap_pts: vec![(center, SnapHint::Center)],
tangent_geoms: vec![],
key_vertices: vec![[x0, y0, z], [x1, y1, z]],
fill_tris: vec![],
}
}
+1
View File
@@ -22,6 +22,7 @@ fn to_truck(pt: &Point) -> TruckEntity {
snap_pts: vec![(snap, SnapHint::Node)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
}
}
+5 -1
View File
@@ -31,6 +31,7 @@ fn tessellate_polyline(pl: &Polyline) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: key_verts,
fill_tris: vec![],
}
}
@@ -127,6 +128,7 @@ fn tessellate_polyline2d(pl: &Polyline2D) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
};
}
@@ -204,7 +206,7 @@ fn tessellate_polyline2d(pl: &Polyline2D) -> TruckEntity {
if i + 1 < kv.len() { pts.push([f32::NAN; 3]); }
}
}
return TruckEntity { object: TruckObject::Lines(pts), snap_pts: vec![], tangent_geoms: tgs, key_vertices: kv };
return TruckEntity { object: TruckObject::Lines(pts), snap_pts: vec![], tangent_geoms: tgs, key_vertices: kv, fill_tris: vec![] };
}
for i in 0..seg_count {
@@ -271,6 +273,7 @@ fn tessellate_polyline2d(pl: &Polyline2D) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: tangents,
key_vertices: key_verts,
fill_tris: vec![],
}
}
@@ -397,6 +400,7 @@ fn tessellate_polyline3d(pl: &Polyline3D) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: key_verts,
fill_tris: vec![],
}
}
+2
View File
@@ -129,6 +129,7 @@ impl TruckConvertible for RasterImage {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: corners.to_vec(),
fill_tris: vec![],
})
}
}
@@ -289,6 +290,7 @@ impl TruckConvertible for Wipeout {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: corners.to_vec(),
fill_tris: vec![],
})
}
}
+2
View File
@@ -34,6 +34,7 @@ impl TruckConvertible for Ray {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![start],
fill_tris: vec![],
})
}
}
@@ -165,6 +166,7 @@ impl TruckConvertible for XLine {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![[bp.x as f32, bp.y as f32, bp.z as f32]],
fill_tris: vec![],
})
}
}
+1
View File
@@ -47,6 +47,7 @@ impl TruckConvertible for Shape {
snap_pts: vec![(snap_pt, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![[ox, oy, oz]],
fill_tris: vec![],
})
}
}
+1
View File
@@ -47,6 +47,7 @@ impl TruckConvertible for Solid {
snap_pts: snap,
tangent_geoms: vec![],
key_vertices: vec![p0, p1, p2, p3],
fill_tris: vec![],
})
}
}
+2
View File
@@ -19,6 +19,7 @@ fn to_truck(spl: &Spline) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
};
}
@@ -92,6 +93,7 @@ fn to_truck(spl: &Spline) -> TruckEntity {
snap_pts: vec![],
tangent_geoms: vec![],
key_vertices,
fill_tris: vec![],
}
}
+1
View File
@@ -137,6 +137,7 @@ impl TruckConvertible for Table {
snap_pts: vec![(origin, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
})
}
}
+1
View File
@@ -125,6 +125,7 @@ fn to_truck(t: &Text, document: &acadrust::CadDocument) -> TruckEntity {
snap_pts: vec![(snap_pt, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
}
}
+1
View File
@@ -236,6 +236,7 @@ impl TruckConvertible for Tolerance {
snap_pts: vec![(snap_pt, SnapHint::Insertion)],
tangent_geoms: vec![],
key_vertices: vec![],
fill_tris: vec![],
})
}
}
+2
View File
@@ -56,6 +56,7 @@ impl TruckConvertible for Underlay {
snap_pts: vec![(Vec3::from(origin), SnapHint::Node)],
tangent_geoms: vec![],
key_vertices: key,
fill_tris: vec![],
})
} else {
// No clip boundary: draw a cross at insertion point.
@@ -65,6 +66,7 @@ impl TruckConvertible for Underlay {
snap_pts: vec![(Vec3::from(origin), SnapHint::Node)],
tangent_geoms: vec![],
key_vertices: vec![origin],
fill_tris: vec![],
})
}
}