Skip to content

perf(FragmentsModels): hierarchical frustum culling via the existing spatial lookup - #285

Open
rihokirss wants to merge 1 commit into
ThatOpen:mainfrom
rihokirss:perf/c4d-hierarchical-cull
Open

perf(FragmentsModels): hierarchical frustum culling via the existing spatial lookup#285
rihokirss wants to merge 1 commit into
ThatOpen:mainfrom
rihokirss:perf/c4d-hierarchical-cull

Conversation

@rihokirss

@rihokirss rihokirss commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Closes #280.

The per-view cull pass tested every sample's box against the frustum and clipping planes individually — a flat O(samples) sweep per model on every real view change, even when most of the model is far outside the view (the normal case for interior navigation). The spatial hierarchy that already exists for raycasting (VirtualBoxStructure) now feeds the same pass:

  • VirtualBoxCollider gains an allocation-free mask traversal (frustumFillOutsideMask) sharing the exact walk and plane semantics of frustumCollide; collide() is refactored onto the shared traversal so the two cannot drift apart.
  • VirtualTilesController rebuilds a per-sample outside-mask on every real view change. Samples in branches that provably miss the view skip the per-sample plane math; every candidate still runs the exact original test, so the final classification of any sample is unchanged.
  • Fully-included branches collect their leaves without per-leaf box tests, so the whole-model-in-view case stays fast too.

Measurements

13 real project models (.frag, converted from IFC; headless Chromium): interior look-around CPU −14 %, settle after orbiting 44 ms → 23 ms, idle and whole-building orbit unchanged.

8 models on a Radeon 780M, exterior poses only (which is the case this optimisation helps least, everything is in view): neutral within noise, draw calls identical, tile batches per 5 s orbit 680 → 725. Verified identical rendered triangle counts across fixed camera poses, within the pre-existing run-to-run noise of the LRU mesh cache; a same-build control run shows the same noise.

Screenshot diff over six fixed poses: 0.000 % on five, 0.07 % on one — one façade strip where two coplanar surfaces z-fight and the tile that arrives first wins, so any change in tile arrival order flips it.

🤖 Generated with Claude Code

https://claude.ai/code/session_013rtNQqhSQRM2t6E98DESNE

…spatial lookup

The per-view cull pass tested every sample's box against the frustum
and clipping planes individually — a flat O(N) sweep per model on every
real view change, even when most of the model was far outside the view
(typical for interior navigation). The spatial hierarchy that already
exists for raycasting (VirtualBoxStructure) now feeds the same pass:

- VirtualBoxCollider gains an allocation-free mask traversal
  (frustumFillOutsideMask) sharing the exact walk and plane semantics
  of frustumCollide; collide() is refactored onto the shared traverse.
- VirtualTilesController rebuilds a per-sample outside-mask on every
  real view change. Samples in branches that provably miss the view
  skip the per-sample plane math; every candidate still runs the exact
  original test, so the final classification of any sample is
  unchanged (verified: identical rendered triangle counts across fixed
  camera poses, within the pre-existing run-to-run noise of the
  LRU-based mesh cache; a same-build control run shows equal noise).
- Fully-included branches collect their leaves without per-leaf box
  tests, so the whole-model-in-view case stays fast too.

Measured with 13 real IFC-derived models (headless Chromium): interior
look-around CPU -14%, settle after orbiting 44 ms -> 23 ms, idle and
whole-building orbit unchanged.
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.

The per-view cull pass tests every sample's box although VirtualBoxStructure already provides a spatial hierarchy

1 participant