-
Notifications
You must be signed in to change notification settings - Fork 263
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
Restructure zone view lighting #3813
Restructure zone view lighting #3813
Conversation
At the core of this change is the addition of `Illuminator` and its result type `Illumination`. An `Illuminator` holds all areas lit by normal lights, and associates them with their lumens value (this is actually done per sight multiplier since that can change the light areas). It can then produce an `Illumination` that holds the various lumens levels as unioned areas, from which we can calculate some derivate results such as which areas are lit and which areas are covered in darkness. The `Illuminator` is also able to add and remove individual areas and will only recalculate the effected lumens level. The caching in `ZoneView` has also been reworked so that more information can be kept as things change. The main lighting results are cached per `IlluminationKey` (which is just a sight multiplier for now) and which can be reused for every token involved in a view. Other results are cached per `PlayerView`. This includes some results that were previously specific to the current `PlayerView` being rendered, but now are stored in a `Map` so that they can still be reused across view changes. As a result, view changes no longer require flushing the `ZoneView`, and correspondingly the `zoneView.flush()` call has bee removed from `ZoneRenderer.invalidateCurrentViewCache()`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't claim that I completely understand ZoneView but the code looks reasonable. I'm a bit surprised that we don't use the direction of a light anywhere. Don't we have light cones?
src/main/java/net/rptools/maptool/client/ui/zone/Illuminator.java
Outdated
Show resolved
Hide resolved
- Renamed `Illuminator.Node` to `Illumination.Node` and added more documentation. - Factored out the path extension so we don't duplicate the details of getting a path iterator from a `LitArea`.
Rather than unioning every token's vision, we can instead use the visible area of the view's illumination result. That already accounts for each token's personal lights and sight multipliers.
That |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 15 of 17 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kwvanderlinde)
Identify the Bug or Feature request
Implements #3747
Description of the Change
The main purpose was to improve the performance of personal lighting. The performance itself is mildly improved, though the main benefit is increased responsiveness when switching
PlayerView
s. There is still room for improvement as personal lights still have a noticeable impact above and beyond normal lights.The secondary purpose of this change was to enable some different approaches to lights. E.g. I am experimenting with splitting the lumens display out from light blending, which is one of the things that is made easier due to the new
Illuminator
providing a more complete picutre of the lighting situation.At the core of this change is the addition of
Illuminator
and its result typeIllumination
. AnIlluminator
holds all areas lit by normal lights, and associates them with their lumens value (this is actually done per sight multiplier since that can change the light areas). It can then produce anIllumination
that holds the various lumens levels as unioned areas, from which we can calculate some derivate results such as which areas are lit and which areas are covered in darkness. TheZoneView
is then able to use this "global" result and mix in personal lighting information in order to produce a final result.The caching in
ZoneView
has also been reworked so that more information can be kept as things change. The main lighting results are cached perIlluminationKey
(which is just a sight multiplier for now) and which can be reused for every token involved in a view. Other results are cached perPlayerView
. This includes some results that are specific to the currentPlayerView
being rendered, but now are stored in aMap
so that they can still be reused even when changing back and forth betweenPlayerView
s. As a result, view changes no longer require flushing theZoneView
, and correspondingly thezoneView.flush()
call has been removed fromZoneRenderer.invalidateCurrentViewCache()
.A couple minor changes for things discovered during this work as well:
FogUtil.calculateVisibility()
is no longer responsible for translating areas according to the visibility origin. That responsibility is now left to the callers, and enables some call sites to be a bit more streamlined then they would otherwise be in terms of managing lit areas.Direction
enum has been removed as onlyDirection.CENTER
was actually used. This also mean we don't have to try and account for it in any caching.CodeTimer
was tweaked so it doesn't repeat ordering numbers when a single timer is encountered multiple times.Possible Drawbacks
There is a bit more going on, so there is the possibility of missing something. E.g., not flushing illumination results properly. This would appear as lights not appearing, or appearing in the wrong place.
Documentation Notes
N/A (internal change)
Release Notes
This change is