GPv3: Insert duplicate keyframe when erasing

When drawing is visible in 3d-view and playhead is not over keyframe, in
such case erase tool is erases everything (or let's say it adds empty
keyframe). Erasing works correctly if additive drawing is enabled but
this is also expected to work when additive drawing is disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/119051
This commit is contained in:
Pratik Borhade
2024-03-15 12:12:21 +01:00
committed by Falk David
parent 96a8f5b36c
commit 47940cdb5b

View File

@@ -350,9 +350,13 @@ bool ensure_active_keyframe(const Scene &scene, GreasePencil &grease_pencil)
(*active_layer.frame_key_at(current_frame) < current_frame);
if (blender::animrig::is_autokey_on(&scene) && needs_new_drawing) {
if ((scene.toolsettings->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) != 0) {
const Brush *brush = scene.toolsettings->gp_paint->paint.brush;
if (((scene.toolsettings->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) != 0) ||
(brush->gpencil_tool == GPAINT_TOOL_ERASE))
{
/* For additive drawing, we duplicate the frame that's currently visible and insert it at the
* current frame. */
* current frame. Also duplicate the frame when erasing, Otherwise empty drawing is added,
* see !119051 */
grease_pencil.insert_duplicate_frame(
active_layer, *active_layer.frame_key_at(current_frame), current_frame, false);
}