Skip to content

Fix frame drops caused by objects in another dimension - #5306

Open
Flashmyname wants to merge 1 commit into
multitheftauto:masterfrom
Flashmyname:fix/5261-streamer-dimension-distance
Open

Fix frame drops caused by objects in another dimension#5306
Flashmyname wants to merge 1 commit into
multitheftauto:masterfrom
Flashmyname:fix/5261-streamer-dimension-distance

Conversation

@Flashmyname

@Flashmyname Flashmyname commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Objects sitting in another dimension still cost frame time, and the cost scales with the model's bounding radius. CClientStreamer::DoPulse recomputes every active element's distance each frame before Restream looks 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 in CClientObject.cpp:238, CClientPed.cpp:4197 and CClientVehicle.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 fpslimit 0, vsync off.

before after
5000 x model 4449 (radius 330), dimension 1 +3.2 ms/frame (1205 -> 248 fps) +0.5-0.7 ms/frame (1235 -> 663-781 fps, two sessions)
5000 x model 1337 (radius 0.8), dimension 1 +0.4 ms/frame +0.4 ms/frame

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Copilot AI lite review requested due to automatic review settings September 2, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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::GetDistanceToBoundingBoxSquared to 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.

Comment thread Client/mods/deathmatch/logic/CClientStreamElement.cpp Outdated
Copilot AI review requested due to automatic review settings September 2, 2026 14:56
@Flashmyname
Flashmyname force-pushed the fix/5261-streamer-dimension-distance branch from 03be741 to 1525ad2 Compare September 2, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped and aligns with existing streamer dimension-gating logic, with only a minor consistency tweak suggested.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread Client/mods/deathmatch/logic/CClientStreamElement.cpp Outdated
Copilot AI review requested due to automatic review settings September 2, 2026 19:10
@Flashmyname
Flashmyname force-pushed the fix/5261-streamer-dimension-distance branch from 1525ad2 to 125a9d2 Compare September 2, 2026 19:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

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.

Objects in different dimensions cause frame drop

2 participants