GPv3: Insert keyframe when drawing if no key exists at current frame

Code to insert new keyframe when drawing is included in
7e87435cf4 . But current condition fails
to add new frame. In `frame_key_at()`, last drawing or the next drawing is
returned (instead of -1). Hence, no new drawing/frame was added in draw-invoke
function.
So add keyframe if no keyframe exists already at `current_number`

Pull Request: https://projects.blender.org/blender/blender/pulls/113408
This commit is contained in:
Pratik Borhade
2023-10-09 12:54:42 +02:00
committed by Pratik Borhade
parent 03040f3b7f
commit f37a8cda30

View File

@@ -140,7 +140,8 @@ static int grease_pencil_stroke_invoke(bContext *C, wmOperator *op, const wmEven
}
const int current_frame = scene->r.cfra;
if (grease_pencil.get_active_layer()->drawing_index_at(current_frame) == -1) {
if (!grease_pencil.get_active_layer()->frames().contains(current_frame)) {
if (!IS_AUTOKEY_ON(scene)) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil frame to draw on");
return OPERATOR_CANCELLED;