Is there a way to determine whether an entity is currently being rendered to any player?
I would like to improve the performance of a mod by not processing entities that are not in any view.
The only way I can think of is to check every player, check whether they are in map view, if they are on the right surface, what their zoom level, resolution and display density scale are and then manually calculate whether a given entity should be able to be seen.
This sounds very CPU intensive to do every tick, and doesn't take into account a GUI camera for example.
Doe anyone know of a better way to do this?
Worst case, I'll just check whether any player is in camera view (not map view) on the surface the entity is on, without taking proximity into account.
Determining whether an entity is currently in view
-
- Burner Inserter
- Posts: 9
- Joined: Fri Nov 01, 2024 12:27 pm
- Contact:
Re: Determining whether an entity is currently in view
for display resolution and scale, you have events (search for "display") that you can listen on, thus calculating the "viewport" only during these events and storing it. For the zoom, you could create a custom event that binds to the mouse wheel, but the best approach would be to just assume the farest zoom.
GUI cameras are treated differently but they are mostly static I think. There are several gui element events that may help
GUI cameras are treated differently but they are mostly static I think. There are several gui element events that may help