Fix #134984: Grease Pencil: Applying a modifier clears keyframe of hidden layer

This was happening because in `apply_eval_grease_pencil_data`
we gather all the potential original layers to clear. This was done
by taking the set of all original layers and then removing layers
from the set that map to an evaluated layer.
The remaining layers are unmapped and should be cleared.

The problem is that invisible layers are no longer part of evaluated
data so there wouldn't be a mapping that could be found.

To fix this, we don't initialize the set of `orig_layers_to_clear` to
all the layers, but instead to only the layers that are visible.
This will ensure that we don't clear keyframes of hidden layers.

Pull Request: https://projects.blender.org/blender/blender/pulls/135121
This commit is contained in:
Falk David
2025-02-25 18:36:53 +01:00
committed by Falk David
parent 8f1d03cd75
commit ddced37ea4

View File

@@ -1011,7 +1011,13 @@ static void apply_eval_grease_pencil_data(const GreasePencil &src_grease_pencil,
Map<const LayerGroup *, TreeNode *> last_node_by_group;
/* Set of orig layers that require the drawing on `eval_frame` to be cleared. These are layers
* that existed in original geometry but were removed during the modifier evaluation. */
Set<Layer *> orig_layers_to_clear(orig_grease_pencil.layers_for_write());
Set<Layer *> orig_layers_to_clear;
for (Layer *layer : orig_grease_pencil.layers_for_write()) {
/* Only allow clearing a layer if it is visible. */
if (layer->is_visible()) {
orig_layers_to_clear.add(layer);
}
}
for (const TreeNode *node_eval : merged_layers_grease_pencil.nodes()) {
/* Check if the original geometry has a layer with the same name. */
TreeNode *node_orig = orig_grease_pencil.find_node_by_name(node_eval->name());