Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ZoneView to keep lighting consistent #3952

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Apr 17, 2023

Identify the Bug or Feature request

Fixes #3905

Description of the Change

ZoneView.illuminators and ZoneView.contributedLightsByToken have been moved into a new IlluminationModel that tracks a single Illuminator 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 replaces ZoneView.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 via ZoneView.illuminationsPerView.

ZoneRenderer no longer caches drawable lights and auras because it's possible for it to get out-of-sync with the underlying ZoneView. Instead, ZoneView caches DrawableLight on a per-view basis, and DrawableAuras 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 have IlluminationModel to keep the contributions and illuminators in-sync, and now that DrawableLights and DrawableAuras are cached in ZoneView and we don't have to worry about any potentially delays in ZoneView flushing relative to the ZoneRenderer.

Possible Drawbacks

Possibility of exposing other multithreading issues.

Documentation Notes

N/A

Release Notes

N/A


This change is Reviewable

`ZoneView.illuminators` and `ZoneView.contributedLightsByToken` have been moved into a new `IlluminationModel` that
tracks a single `Illuminator` 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 replaces
`ZoneView.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 via `ZoneView.illuminationsPerView`.

`ZoneRenderer` no longer caches drawable lights and auras because it's possible for it to get out-of-sync with the
underlying `ZoneView`. Instead, `ZoneView` caches `DrawableLight` on a per-view basis, and `DrawableAuras`
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 have
`IlluminationModel` to keep the contributions and illuminators in-sync, and now that `DrawableLight`s and
`DrawableAura`s are cached in ZoneView and we don't have to worry about any potentially delays in `ZoneView` flushing
relative to the `ZoneRenderer`.
@cwisniew cwisniew merged commit 7c40324 into RPTools:release-1.13 Apr 17, 2023
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/3905-cme-canSeeToken-1.13 branch April 17, 2023 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants