multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 425 forks source link

Rain is eating performance #2304

Open Einheit-101 opened 3 years ago

Einheit-101 commented 3 years ago

Description setRainLevel() impacts performance which scales linear with existing collision shapes in the surrounding area. More complex collisions - less fps Higher rain level - less fps

setRainLevel(0) = 98 fps setRainLevel(0.5) = 90 fps setRainLevel(1) = 85 fps setRainLevel(2) = 80 fps

crun for i, obj in pairs(getElementsByType("object")) do setElementCollisionsEnabled(obj, false) end Disabling all collisions in the area = 98 fps again

To reproduce

  1. Create 10 cars
  2. srun setFPSLimit(99)
  3. setRainLevel(2)
  4. FPS will most likely drop depending on CPU power

image

Possible solution Make it possible for rain to ignore collisions and add it as argument in setRainLevel() or add a new function setRainCollisions(bool). It should be doable.

Multi Theft Auto v1.5.8-release-20881.2

Einheit-101 commented 3 years ago

for i=2, 15 do setWorldSoundEnabled(6, i, false, true) end

^ This reduces my fps drop from -20 to -5 fps

patrikjuvonen commented 3 years ago

The obvious catch here is that if we disable collision detection the rain would fall through the ground so you don't any drop effects.

(Just had to point this out here)

Einheit-101 commented 3 years ago

The problem is that i dont see any drop effects on regular ground anyway, just on Peds and vehicles. However it still calculates these collisions. Maybe we could toggle to disable this, if it saves performance.

Allerek commented 3 years ago

As i see, the rain effect is not reversed yet, so this should be done to point the exact source of this problem.

ArranTuna commented 3 years ago

for i=2, 15 do setWorldSoundEnabled(6, i, false, true) end

^ This reduces my fps drop from -20 to -5 fps

So this is basically a report about https://github.com/multitheftauto/mtasa-blue/issues/1067 then.

Einheit-101 commented 3 years ago

Even with #1067 sorted out we still lose 5 fps, which could be fixed aswell.

Pirulax commented 3 years ago

I'll make a build with and without OnClientWorldSound.. I'm really curious whenever that would solve it.