code wiki / (root) / nx_mesh_qem.nx

nx_mesh_qem.nx

buildroot/runtime/nx_mesh_qem.nx

7866 B187 linesdepth 6pulls 7 transitivereach 1 importersview sourcekind librarytopic mesh
docsdependenciesstructsconstsfunctions

about

nx_mesh_qem.nx -- mesh decimation by QUADRIC ERROR METRICS (Garland-Heckbert 1997), pure integer. Each vertex accumulates a quadric Q (sum of outer products of its incident face planes); collapsing an edge costs p^T Q p (the squared distance of the new point to those planes). Collapsing LOWEST-cost edges first => flat regions decimate hard while curved/feature regions keep their vertices -- the quality win over uniform vertex clustering (nx_mesh_decimate) on CURVED geometry. Sovereign + no-float: the mesh is scaled into a bounded [0,1024] cube so the integer quadrics never overflow i64; collapse uses MIDPOINT placement (no matrix inverse). Reuses nx_mesh + nx_isqrt. license_tier: ORIGINAL

dependencies 4 imports · 1 importers

nx_syscalls.nx nx_mesh.nx nx_mesh_print_check.nx nx_isqrt.nx nx_mesh_qem.nx nx_mesh_qem_gate.nx

imports: nx_syscalls.nxnx_mesh.nxnx_mesh_print_check.nxnx_isqrt.nx

imported by: nx_mesh_qem_gate.nx

structs

none

consts

14const QEM_S: i64 = 1024 // normalized cube side
15const QEM_NQ: i64 = 256 // normal fixed-point scale

functions

18func qem_add(quad: *i64, v: i64, a: i64, b: i64, c: i64, d: i64) -> i64
called by 1: nx_mesh_qem
34func qem_cost(quad: *i64, va: i64, vb: i64, px: i64, py: i64, pz: i64) -> i64
called by 1: nx_mesh_qem
47func nx_mesh_qem(m: *NxMesh, target_tris: i64) -> *NxMesh