perf(FragmentsModels): hierarchical frustum culling via the existing spatial lookup - #285
Open
rihokirss wants to merge 1 commit into
Open
perf(FragmentsModels): hierarchical frustum culling via the existing spatial lookup#285rihokirss wants to merge 1 commit into
rihokirss wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:VirtualBoxCollidergains an allocation-free mask traversal (frustumFillOutsideMask) sharing the exact walk and plane semantics offrustumCollide;collide()is refactored onto the shared traversal so the two cannot drift apart.VirtualTilesControllerrebuilds 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.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