From 99bf9f45343f7261c1fa6ca4a887cd28f5ccf643 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Mon, 30 Sep 2024 10:48:54 +0200 Subject: [PATCH] GPv3: Add keys to all layers in sculpt mode When auto key is enabled, add keys to all layers in sculpt mode. After 37458329e2, `ensure_active_keyframe` accepts layer argument. Run a loop over all the layers, call above function to handle keyframe/drawing at current frame. Resolves #127650. Pull Request: https://projects.blender.org/blender/blender/pulls/127849 --- .../sculpt_paint/grease_pencil_draw_ops.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc b/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc index e22b509f705..2ea0cebe5fe 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc @@ -359,15 +359,18 @@ static int grease_pencil_sculpt_paint_invoke(bContext *C, wmOperator *op, const /* For the sculpt tools, we don't want the auto-key to create an empty keyframe, so we duplicate * the previous key. */ const bool use_duplicate_previous_key = true; - if (!ed::greasepencil::ensure_active_keyframe( - *scene, grease_pencil, active_layer, use_duplicate_previous_key, inserted_keyframe)) - { + for (bke::greasepencil::Layer *layer : grease_pencil.layers_for_write()) { + if (ed::greasepencil::ensure_active_keyframe( + *scene, grease_pencil, *layer, use_duplicate_previous_key, inserted_keyframe)) + { + inserted_keyframe = true; + } + } + if (!inserted_keyframe) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil frame to draw on"); return OPERATOR_CANCELLED; } - if (inserted_keyframe) { - WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr); - } + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr); op->customdata = paint_stroke_new(C, op,