Skip to content

cvc/geometry: native (VTK-free) QEM mesh simplifier (cvc::simplify) - #483

Merged
transfix merged 1 commit into
masterfrom
feat/lod-qem-simplify
Sep 30, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/lod-qem-simplify

Conversation

@transfix

Copy link
Copy Markdown
Owner

Why

The mesh-decimation foundation for auto LOD pyramids. cvc::lod::select ships the selection math but is explicit that "nothing here streams, caches, evicts, decimates or draws." The only triangle reducer in the tree is vtkQuadricDecimation inlined into nav_city_drive/nav_city_swarm, which sits above the "no VTK" line — so it's unavailable to pycvc, headless bake tools, and wasm. This adds the hermetic decimator those need.

What

cvc::simplify(mesh, params, &result, pool) — Quadric Error Metrics half-edge collapse:

  • Snaps the higher-error endpoint onto the lower-error one → surviving vertices never move and keep their exact position/uv/color. Robust (no optimal-placement 3×3 solve or singular fallbacks) and attribute-safe across uv seams.
  • Per-vertex Garland–Heckbert quadrics (area-weighted). Boundary edges add a perpendicular constraint plane so open borders hold. A per-face normal-flip test rejects fold-overs, so the coarse rung never self-intersects.
  • Stops on a triangle target (target_tris/target_ratio) or an error budget (max_error), whichever binds, and reports a measured world-space error per rung — which feeds cvc::lod::world_error_for_switch_radius directly.

Parallelism

The embarrassingly-parallel setup — per-face plane quadrics and the per-vertex quadric gather — fans over the app compute pool (mesh.ctx().computePool()); the greedy collapse loop is inherently serial. The natural scatter is refactored into two data-parallel gathers via the vertex→face adjacency, so the pooled result is bit-identical to serial (asserted).

Test — cvc_geometry_simplify_test (7 cases, all green)

Flat sheet → ~zero error + hard decimation; curved sheet reduces with no NaNs / degenerate faces / count growth; bounding box + boundary preserved; pooled == serial bit-for-bit; error-budget early stop; empty + over-target no-ops.

Series

First of the LOD-pyramid work. Next: cvc::lod::pyramid_builder (mesh via this, volume via vol_downsample/voxels::resize, image via a new quality downsampler), the per-bundle scene.cvch5 HDF5 store (defining the reserved /cvc/geometry schema + a lod_index), and the scene-renderer LodGraphicsNode + per-frame rung selection. Design summary in the linked discussion.

The mesh-decimation foundation for the LOD pyramid. cvc::lod::select ships the
selection math but "nothing here streams, caches, evicts, decimates or draws";
the only triangle reducer in the tree is vtkQuadricDecimation inlined in the nav
demos, which lives above the "no VTK" line and so is unavailable to pycvc,
headless bake tools, and wasm. This adds a hermetic Quadric Error Metrics
decimator: rung 0 is the full mesh, coarser rungs are simplify()'d copies whose
MEASURED world-space error feeds cvc::lod's world_error_m ladder directly.

Half-edge collapse (snap the higher-error endpoint onto the lower-error one), so
surviving vertices never move and keep their exact position/uv/color — robust
(no optimal-placement solve or singular fallbacks), attribute-safe across uv
seams, and a good fit for the feature-aligned architectural meshes it first
targets (Austin buildings, Humvee). Per-vertex Garland-Heckbert quadrics;
boundary edges add a perpendicular constraint plane so open borders hold;
fold-overs are rejected by a per-face normal-flip test. Stops on a triangle
target or an error budget, whichever binds.

The embarrassingly-parallel setup (per-face plane quadrics + per-vertex quadric
gather) fans over the app compute pool (mesh.ctx().computePool()); the greedy
collapse loop is serial. The scatter is refactored into two data-parallel
gathers via the vertex->face adjacency, so the pooled result is BIT-IDENTICAL to
serial (asserted by the test).

Gate cvc_geometry_simplify_test: flat sheet -> ~zero error + hard decimation;
curved sheet reduces without NaNs/degenerate faces/count growth; bounding box +
boundary preserved; pooled == serial bit-for-bit; error-budget early stop; empty
and over-target no-ops.

First of the LOD-pyramid series (next: cvc::lod::pyramid_builder for mesh/volume/
image rungs, the scene.cvch5 HDF5 store, and the scene-renderer LodGraphicsNode).
@transfix
transfix merged commit 34c02a6 into master Sep 30, 2026
17 of 18 checks passed
@transfix
transfix deleted the feat/lod-qem-simplify branch October 29, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant