fix(solid): use kernel geometry

Derive extrusion, bounds, edges, and fill from cadkernel while preserving precise view filtering and stable GPU uploads.
This commit is contained in:
Hakan Seven committed 2026-08-21 19:47:03 +03:00
1 parent 17dc0aff39
commit ee89458f8a
5 files changed
+225 -104

No files matched your search

+36 -8
View File
@@ -22,20 +22,48 @@ use crate::scene::model::wire_model::WireModel;
use iced::wgpu;
use iced::wgpu::util::DeviceExt;
fn planar_solid_faces_view(wire: &WireModel, view_dir: glam::Vec3) -> bool {
pub(crate) fn planar_solid_faces_view(wire: &WireModel, view_dir: glam::Vec3) -> bool {
if !wire.fill_is_2d_solid || wire.fill_is_3d {
return true;
}
let view = view_dir.normalize_or_zero();
wire.fill_tris.chunks_exact(3).any(|triangle| {
let first = glam::Vec3::from_array(triangle[0]);
let second = glam::Vec3::from_array(triangle[1]);
let third = glam::Vec3::from_array(triangle[2]);
let view = view_dir.as_dvec3().normalize_or_zero();
let point = |index: usize| {
let high = wire.fill_tris[index];
let low = wire
.fill_tris_low
.get(index)
.copied()
.unwrap_or([0.0; 3]);
glam::DVec3::new(
high[0] as f64 + low[0] as f64,
high[1] as f64 + low[1] as f64,
high[2] as f64 + low[2] as f64,
)
};
(0..wire.fill_tris.len() / 3).any(|triangle| {
let first = point(triangle * 3);
let second = point(triangle * 3 + 1);
let third = point(triangle * 3 + 2);
let normal = (second - first).cross(third - first).normalize_or_zero();
normal.length_squared() > 0.0 && normal.dot(view).abs() >= 1.0 - 1.0e-5
})
}
pub(crate) fn planar_solid_visibility_key(
wires: &[WireModel],
view_dir: glam::Vec3,
) -> u64 {
let mut key = 0xcbf29ce484222325_u64;
for wire in wires
.iter()
.filter(|wire| wire.fill_is_2d_solid && !wire.fill_is_3d)
{
key ^= planar_solid_faces_view(wire, view_dir) as u64;
key = key.wrapping_mul(0x100000001b3);
}
key
}
// ── Vertex layout ──────────────────────────────────────────────────────────
#[repr(C)]
@@ -88,8 +116,8 @@ impl Face3DVertex {
// ── GPU handle ─────────────────────────────────────────────────────────────
/// One vertex buffer + draw count. Fill data is split into as many chunks
/// as the device's `max_buffer_size` requires: a mesh-heavy DWG (e.g. a
/// Navisworks import) can hold tens of millions of fill triangles, and at
/// as the device's `max_buffer_size` requires: a mesh-heavy drawing can hold
/// tens of millions of fill triangles, and at
/// 44 B/vertex a single batched buffer blows past the default 256 MB limit
/// once enough layers are thawed — wgpu then raises an uncaptured
/// validation error and aborts the process (#358). Same scheme as the