From ddced37ea49e1875e2baaa67021ee337f9d38697 Mon Sep 17 00:00:00 2001 From: Falk David Date: Tue, 25 Feb 2025 18:36:53 +0100 Subject: [PATCH] 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 --- source/blender/editors/object/object_modifier.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index c31f383b526..651ce392a7d 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -1011,7 +1011,13 @@ static void apply_eval_grease_pencil_data(const GreasePencil &src_grease_pencil, Map 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 orig_layers_to_clear(orig_grease_pencil.layers_for_write()); + Set 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());