Fix frame drops caused by objects in another dimension - #5306
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is small, targeted, and aligns with existing dimension-based streaming behavior while reducing unnecessary per-frame work.
Pull request overview
This PR optimizes client-side streaming distance calculations to avoid expensive bounding-box distance work for elements that are streamed out and in a different dimension than the streamer, addressing reported frame drops when many large-radius objects exist in another dimension.
Changes:
- Short-circuit
CClientStreamElement::GetDistanceToBoundingBoxSquaredto use plain squared distance when the element is streamed out and dimension-mismatched (and not visible in all dimensions). - Avoids per-frame matrix fetch + oriented box distance computation for elements that cannot stream in due to dimension filtering.
File summaries
| File | Description |
|---|---|
| Client/mods/deathmatch/logic/CClientStreamElement.cpp | Adds an early-return fast path for streamed-out elements in another dimension to reduce streamer CPU cost. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
03be741 to
1525ad2
Compare
1525ad2 to
125a9d2
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The change is small, localized, and aligns with the existing dimension gating in CClientStreamer::Restream while reducing per-frame work without altering streaming eligibility.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
Objects sitting in another dimension still cost frame time, and the cost scales with the model's bounding radius.
CClientStreamer::DoPulserecomputes every active element's distance each frame beforeRestreamlooks at the dimension, and for a radius of 20 or more that means an entity matrix fetch plus an oriented box distance - work whose result is thrown away a few lines later.Use the plain squared distance for elements that are streamed out and in another dimension. It is never smaller than the box distance, so nothing sorts closer than before, and those elements can't stream in anyway.
The condition is the negation of the stream-in gate in
Restream(CClientStreamer.cpp:489), and the same expression already appears inCClientObject.cpp:238,CClientPed.cpp:4197andCClientVehicle.cpp:3210.Motivation
Fixes #5261. Same setup as reported: 5000 x model 4449 (radius 330) in dimension 1, nothing rendered.
Test plan
Empty sky view so nothing renders and the streamer is the only cost; 15 s frame count per phase, each load phase bracketed by empty phases; server
fpslimit0, vsync off.Checklist