Fix CanvasModulate
logic for modulating the canvas
#79747
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.
CanvasModulate can modulate the canvas only when it is in some canvas and it is visible in the tree.
Previously CanvasModulate would update / try to update the canvas modulate color (within the RenderingServer) always on:
This can fail in many different ways.
Some of them in v4.1.1.stable.official [bd6af8e] (click to expand).
"Fighting" for changing the canvas modulate color (last one changed takes over):
Changing canvas modulate color regardless of other CanvasModulates:
(on deleting:)
Etc.
This PR makes exactly one CanvasModulate be active (affecting the canvas modulation) in each (non-empty) canvas modulate group.
(is_in_canvas, is_visible_in_tree)
tuple changes to / from(true, true)
, it's being added to / removed from the canvas modulate group.Note that for more than one CanvasModulate in the given canvas modulate group it's said it's undefined which one is active. It could be implemented that the active one is always e.g. the topmost according to the tree order, or the one added to the canvas modulate group most/least recently or something like that. However, more than one CanvasModulate in such group is considered an invalid state, hence I find it not worth the additional burden (e.g. for tree ordering CanvasModulates would need to react to parent's
child_order_changed
). I think what's important is that after ending with a single CanvasModulate within such group, it should work as expected. This should be the case with this PR.Fixes #73894.
Fixes #79679.
I think it's good for cherry-picking even if it possibly changes the previous buggy behavior for more than one CanvasModulate in the canvas. That's invalid state which shouldn't be relied upon and the previous message within the in-editor warning:
was misleading / not true anyway.