Refactor ZoneView to keep lighting consistent #3952
Merged
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
Fixes #3905
Description of the Change
ZoneView.illuminators
andZoneView.contributedLightsByToken
have been moved into a newIlluminationModel
that tracks a singleIlluminator
and set of token contributions.ZoneView.getIlluminationModel(IlluminationKey)
returns such a model and ensures that it is up-to-date and contains all necessary light sources. This replacesZoneView.getUpToDateIlluminator()
which has subtle interactions with the state of token contributions.We no longer have
ZoneView.illuminationCache
as it just caches a relatively lightweight intermediate result. We still cache full illumination results viaZoneView.illuminationsPerView
.ZoneRenderer
no longer caches drawable lights and auras because it's possible for it to get out-of-sync with the underlyingZoneView
. Instead,ZoneView
cachesDrawableLight
on a per-view basis, andDrawableAuras
generally. These are kept in sync by invalidating them at the same time as the caches from which they are calculated.Since
ZoneView
's flushing methods can be called off the Swing thread, we now delegate the flushing to the Swing thread. The rest of the ZoneView still expects to run on the Swing thread. We can do this now that we haveIlluminationModel
to keep the contributions and illuminators in-sync, and now thatDrawableLight
s andDrawableAura
s are cached in ZoneView and we don't have to worry about any potentially delays inZoneView
flushing relative to theZoneRenderer
.Possible Drawbacks
Possibility of exposing other multithreading issues.
Documentation Notes
N/A
Release Notes
N/A
This change is