Cache the exposed area used for pathfinding and rendering FoW #3745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Addresses #3744
Description of the Change
This PR adds caching of the view-specific exposed areas. There are a few separate changes that come together to make this happen, which can be seen more easily in the commit history rather than the full diff.
The first major change is to simplify the algorithm for calculating the exposed area. The behaviour is the same, but three of the four special cases have been merged as they actually do the same thing (the fourth case is fundamentally different). Also the calculation of the exposed area is now separated from the rendering logic as the rendering logic was the same for all four cases.
The second major change is to move the exposed area calculation into
ZoneView
where it can be cached. BothZoneRenderer
andAbstractAStarCellWalker
now make use that cache to improve their responsiveness.The final major change is to remove the existing cache of the fog buffer contents. Now that the expensive portion of
renderFog()
is cached in its own right, there is much less benefit to cache the buffer contents. And importantly, the buffer contents would be invalidated anyways in some of the most user-noticeable cases, namely panning/zooming the map. Removing this cache means one less thing forZoneRenderer
to keep track of.Sample times
Some (highly variable) timings for typical
renderFog
runs using the linked campaign in #3744:Of course, when the cache is invalidated, times still aren't especially good, but are typically about 2x better than before the change.
Possible Drawbacks
This change is meant to be a pure refactoring, so shouldn't be any issues unless I changed some subtle behaviour or didn't get the cache invalidation correct.
Documentation Notes
N/A
Release Notes
This change is