Skip to content

cvc/lod + cvcGL: cvc-lod-bake tool, bake_mesh_asset, SceneGraph::selectLOD - #491

Merged
transfix merged 2 commits into
masterfrom
feat/lod-bake-select
Sep 30, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/lod-bake-select

Conversation

@transfix

Copy link
Copy Markdown
Owner

Stacked on #490 (base feat/lod-scene-node). The bake + drive side that makes the pyramid pipeline usable end to end.

What

  • cvc::lod::bake_mesh_asset(ctx, h5file, name, geometry, params, force, pool) — build a mesh's pyramid and cache it in a scene.cvch5, skipping the work when a current pyramid (matching mesh_content_hash) is already present unless force. The reusable core of the tool; a demo bundle bake calls it per glTF mesh it has loaded.
  • cvc-lod-bake CLI (src/cvc/tools) — cvc-lod-bake INPUT.{off,raw} OUTPUT.cvch5 [--name --rungs --ratio --force]. Hermetic (cvc::geometry read; model formats bake from code via bake_mesh_asset). HDF5-gated.
  • cvc::gl::SceneGraph::selectLOD(view) — one per-frame pass that runs every LodGraphicsNode::select() via the existing getAllGraphicsOfType walk; returns the LOD-node count.

The whole chain is now callable: build_mesh_pyramid → bake_mesh_asset / scene.cvch5 (file or blob) → LodGraphicsNode::setPyramid → SceneGraph::selectLOD per frame.

Tests

  • lod_store_test + BakeMeshAssetSkipsWhenCurrent: first bake writes; same mesh skips; --force rebakes; a changed mesh rebakes on the new hash.
  • cvcgl_lod_node + a SceneGraph::selectLOD scenario: far view → coarsest, near → finest, exactly the one LOD node visited.
  • cvc-lod-bake verified end-to-end on a generated OFF grid: bakes a valid HDF5 (\x89HDF), re-run reports up to date, skipped.

This completes the libcvc LOD pipeline. The remaining application step is wiring it into demo3's Austin bundle (CVC-DBG/cvcdbg — cross-repo, wasm demo build): bake buildings.glb into the bundle's scene.cvch5 (or fetch it as a blob), attach a LodGraphicsNode, and call selectLOD each frame.

…ene renderer

The scene-graph seam for LOD: a prop-less GraphicsNode that owns a mesh LOD
ladder (one GeometryNode child per rung, rung 0 = finest) plus the pyramid's
monotone world_error_m ladder, and draws exactly one rung.

select(view) runs the pure math in <cvc/lod/select.h>: the bound-nearest distance
to the node's world bounding sphere (derived from rung 0's extent), then the
hysteretic select_rung over the ladder, then sets exactly the chosen rung's child
visible. Nothing here draws, so the per-frame selection is exercisable with a
null renderer / no GL context; a SceneGraph-level pass or the caller invokes it
each frame. LOD stays a render proxy: a rung is never read by a nav/material/RF
path.

setPyramid(mesh_pyramid) installs the rungs from a built pyramid (cvc::lod), so
the whole chain now composes: build_mesh_pyramid -> [scene.cvch5 cache] ->
setPyramid -> select per frame.

Gate cvcgl_lod_node (headless, plain main/assert like the other cvcGL node
tests): a 3-rung node with a 0/1/4 m error ladder picks the finest rung up close,
the coarsest very far away, and coarsens monotonically as the camera retreats.
…ctLOD

The drive + bake side that makes the pyramid pipeline usable end to end.

  * cvc::lod::bake_mesh_asset(ctx, h5file, name, geometry, params, force, pool)
    -- build a mesh's pyramid and cache it in a scene.cvch5, SKIPPING the work
    when a current pyramid (matching mesh_content_hash) is already present unless
    force. The reusable core of the bake tool; a demo bundle bake calls it on each
    glTF mesh it has loaded.
  * cvc-lod-bake CLI (src/cvc/tools) -- bake INPUT.{off,raw} -> OUTPUT.cvch5
    [--name --rungs --ratio --force]. Hermetic (cvc::geometry read; model formats
    are baked from code via bake_mesh_asset). HDF5-gated.
  * cvc::gl::SceneGraph::selectLOD(view) -- one per-frame pass that runs every
    LodGraphicsNode's select() (via the existing getAllGraphicsOfType walk). The
    caller calls it once per frame; returns the LOD-node count.

The whole chain is now callable: build_mesh_pyramid -> bake_mesh_asset /
scene.cvch5 (file or blob) -> LodGraphicsNode::setPyramid -> SceneGraph::selectLOD
per frame.

Tests: lod_store_test gains BakeMeshAssetSkipsWhenCurrent (first bake writes;
same mesh skips; --force rebakes; a changed mesh rebakes on the new hash) and
cvcgl_lod_node gains a SceneGraph::selectLOD scenario (far view -> coarsest, near
-> finest, exactly the one LOD node visited). cvc-lod-bake verified end-to-end on
a generated OFF grid (bakes a valid HDF5, re-run reports "up to date, skipped").
@transfix
transfix changed the base branch from feat/lod-scene-node to master September 30, 2026 00:55
@transfix transfix closed this Sep 30, 2026
@transfix transfix reopened this Sep 30, 2026
@transfix
transfix merged commit d6ac6a7 into master Sep 30, 2026
17 of 18 checks passed
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