[FIX] Optimize spatial sector detection by skipping updates.#2110
Open
Neloreck wants to merge 1 commit into
Open
[FIX] Optimize spatial sector detection by skipping updates.#2110Neloreck wants to merge 1 commit into
Neloreck wants to merge 1 commit into
Conversation
…ittering objects.
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.
Changes
detect_sector()behindSTYPEFLAG_INVALIDSECTORinR_dsgraph_structure::build_subspace()(renderables) andCRender::Calculate()(near-camera lights); unmoved objects skip both ray casts.SpatialBase::spatial_move()raisesSTYPEFLAG_INVALIDSECTORonly when the object moved more than 1m from its last detection point.SpatialBase::last_sector_point, recorded inspatial_updatesector_internal(), to drive the move threshold.Notes
detectSectormoved into dsgraph #1311 (a8d9187, "xrRender:detectSectormoved into dsgraph") moved the sector raycast out of the flag-guardedSpatialBase::spatial_updatesector_internal()and into the callers inR_dsgraph_structure::build_subspace()andCRender::Calculate(), where it now runs before theSTYPEFLAG_INVALIDSECTORcheck. The guard still exists but only skips storing an already-computed result — so every visible renderable and every near-camera light issues 2CDB::COLLIDER::ray_querycasts on every main pass, even when its sector has not changed. Before xrRender:detectSectormoved into dsgraph #1311 the arg-lessspatial_updatesector()bailed on the flag and never raycast for objects whose sector was still valid.STYPEFLAG_INVALIDSECTORgate at both call sites, and raises the flag inspatial_move()only when the object moved a meaningful distance, so static world geometry and stationary lights reuse their cached sector.CDB::COLLIDER::ray_querydrops from ~604 to ~129 calls/frame (−79%).detectSectormoved into dsgraph #1311 flag-gated behavior. The actor/view-entity shadow path inbuild_subspace()is intentionally left unconditional (single object, negligible cost, avoids any stale-sector risk on the player shadow).Links
Fixes issue introduced in #1311