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
This commit is contained in:
Pratik Borhade
2024-09-30 10:48:54 +02:00
committed by Falk David
parent 3bec05518d
commit 99bf9f4534

View File

@@ -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,