Add configurable object streaming limits (engineSetObjectStreamingLimits)#5055
Open
IOrosa wants to merge 1 commit into
Open
Add configurable object streaming limits (engineSetObjectStreamingLimits)#5055IOrosa wants to merge 1 commit into
IOrosa wants to merge 1 commit into
Conversation
3b52f04 to
512df42
Compare
…its) Dense custom maps hit a hard cap of 500 high-detail streamed-in objects (CClientObjectManager: MAX_OBJECTS_MTA / 2), so decoration stops loading in busy areas even though there is memory to spare. Expose the streaming caps as opt-in client functions, defaulting to stock behaviour: - engineSetObjectStreamingLimits(highDetail, lowLod) - engineGetObjectStreamingLimits() Also relocate the fixed 1000-entry visible-entity / visible-LOD render arrays (CRenderer::ms_aVisibleEntityPtrs / ms_aVisibleLodPtrs) to larger buffers and raise the Check_NoOfVisible* clamps, so the extra objects can render instead of flickering. This is inert with the default limits and does not change stock behaviour (a scene rarely exceeds 1000 visible entities). Related: multitheftauto#869. Raises the object pool ceiling (MAX_OBJECTS_MTA) so the runtime limits may be raised; node pools scale with it. Default streaming stays at 500/500, so the change is fully backward compatible. Refs multitheftauto#5054
512df42 to
265a4f3
Compare
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.
What this does
Implements the configurable limits discussed in #5054.
On maps with a lot of custom-object decoration (e.g. race maps placing thousands of
.mapobjects), decoration stops loading in dense areas and the world flickers. The cause is a
hard cap of 500 high-detail streamed-in objects (
CClientObjectManagersetsm_uiMaxStreamedInCount = MAX_OBJECTS_MTA / 2, withMAX_OBJECTS_MTA = 1000), combinedwith the fixed 1000-entry render lists that flicker when exceeded.
This PR makes those limits opt-in and configurable, with defaults equal to current
behaviour (fully backward compatible):
New client functions
bool engineSetObjectStreamingLimits(int highDetail, int lowLod)— how many high-detail(near) and low-LOD (far) objects may stream in at once. Returns
falseif invalid or thetotal exceeds the object pool.
int, int engineGetObjectStreamingLimits()— current limits.Defaults stay at 500 / 500 (stock), so servers that don't call these are unaffected.
Supporting engine changes
CRenderer::ms_aVisibleEntityPtrs(0xB75898) andms_aVisibleLodPtrs(0xB748F8) to larger buffers and raise theCheck_NoOfVisible*clamps. This lets the extra objects actually render instead of flickering (a long-standing
ask, New Limit Adjuster #869). It is inert with the default limits — a scene rarely exceeds 1000 visible
entities — so it does not change stock behaviour.
MAX_OBJECTS_MTAraised to act as the maximum the runtime limitsmay reach; node pools scale with it.
Why (draw-call trade-off)
Raising these trades FPS for density, so it must be the server/mapper's informed choice —
that's why it's opt-in rather than a global bump. I profiled FPS vs. rendered-object count
while driving a dense map (single machine, DX9, ~52 FPS frame limiter):
Linear fit: ~9.4 FPS lost per 1000 rendered objects, flat at 52 up to ~1800. Low-LOD
objects cost the same as high-detail ones despite far fewer polys, i.e. this is draw-call
bound (CPU/DX9), consistent with #905. On my content,
engineSetObjectStreamingLimits(1500, 800)gave a flat ~52 FPS with ~2x the object density of stock.
Backward compatibility
Testing
Built and tested locally on a dense custom race map:
/start-ing a resource that callsengineSetObjectStreamingLimits(1500, 800)visibly loads far more decoration; changing thevalues at runtime updates streaming immediately; stopping it restores stock (500/500). No
crashes; FPS matches the table above.
Open questions for reviewers
MAX_OBJECTS_MTA) is compile-time, so raisingit costs some memory for everyone even at default limits. Happy to tune the ceiling, make
it configurable, or explore growing the pool on demand — guidance welcome.
engine*functions here; would you also like OOP methods on anEngine class, and/or a getter for current streamed-in counts to help scripts auto-tune?