Extraocular framerate boosting
See original GitHub issueSome of the most fps heavy features of TMPE are around junctions - priority signs, traffic lights, junction restrictions (enter blocked junction), etc.
Vehicle AIs need to use collision detection at junctions just like anywhere else. Which means they are also using vehicle grid.
Could we create a OcularGrid
which is like vehicle grid but just contains flag per cell as to whether that bit of the map is in camera view? (Is there already something like this in vanilla game?) The existing vehicle grid “coordinate” could then be used to check against the ocular grid, minimising grid inspection overheads.
An ‘outer rim’ region could be defined where stuff that’s just out of camera view is treated as in camera view so that if the camera pans a little things on the periphery look more correct.
The OcularGrid
would be recalculated whenever camera moves/tilts/zooms/etc, but would otherwise remain static.
We could then basically skip collision detection and all sorts of other stuff for junctions that are outside camera view. Vehicles would ignore (or just use significantly more basic computations for…) priority signs, traffic lights, junction restrictions and collision detection, and anything else that eats up CPU, when not in camera view.
To retain some sort of reality in terms of traffic congestion reporting, noise pollution, etc., the segments at those junctions would be heavily speed nerfed (in such a way to avoid affecting pathfinder) to compensate for the ignored computations at the junction. We already have speed nerfing architecture as part of priority signs tool (and possibly traffic light tool, especially if #666 is implemented) so it would just hook in to that.
The feature would be optional, via mod options setting, as some users would prefer to keep things as realistic as possible. But for people who want max fps with “good enough” simulation, extraocular framerate boosting could help.
EDIT: We also have simulation accuracy setting (currently missing from mod options) - that too could be greatly reduced for stuff outside of camera view.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (10 by maintainers)
Top GitHub Comments
we could always use an extra set of hands 😃
Test to check if simulation bottleneck fps is pretty simple and you already did it. Move camera to location with nothing to render but still not too far from moving objects (citizens/vehicles). If you stop simulation you should see fps boost, sometimes is little sometimes is significant. I noticed two issues. If you have big city with a lot of moving instances:
num
is the max queue length of all PF internal queues, so each additional 400 queued path more slows down simulation by1ms
A bit more off-topic: I did few experiments trying to figure out if we can add few more PF threads. Here the conclusions:
Summarizing, vanilla game needs 6 fast threads (1 render, 1 sim, 4 PF) and 2 for other less important stuff (audio, water sim, file monitor etc.)
p.s. contact me on Steam or TM:PE discord