[Bf-blender-cvs] [29afadcb15f] master: GPencil: Create new frame when Erase only if additive drawing is enabled

Antonio Vazquez noreply at git.blender.org
Wed May 20 20:34:08 CEST 2020


Commit: 29afadcb15f71119f70f77bcf32c8e54c7614576
Author: Antonio Vazquez
Date:   Wed May 20 20:33:35 2020 +0200
Branches: master
https://developer.blender.org/rB29afadcb15f71119f70f77bcf32c8e54c7614576

GPencil: Create new frame when Erase only if additive drawing is enabled

Differential Revision: https://developer.blender.org/D7804

===================================================================

M	source/blender/editors/gpencil/gpencil_paint.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 309329e4649..4e83c4fb11c 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2071,8 +2071,15 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
     return;
   }
 
-  /* Eraser mode: If no active strokes, just return. */
+  /* Eraser mode: If no active strokes, add one or just return. */
   if (paintmode == GP_PAINTMODE_ERASER) {
+    /* Eraser mode:
+     * 1) Add new frames to all frames that we might touch,
+     * 2) Ensure that p->gpf refers to the frame used for the active layer
+     *    (to avoid problems with other tools which expect it to exist)
+     *
+     * This is done only if additive drawing is enabled.
+     */
     bool has_layer_to_erase = false;
 
     LISTBASE_FOREACH (bGPDlayer *, gpl, &p->gpd->layers) {
@@ -2081,12 +2088,27 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
         continue;
       }
 
+      /* Add a new frame if needed (and based off the active frame,
+       * as we need some existing strokes to erase)
+       *
+       * Note: We don't add a new frame if there's nothing there now, so
+       *       -> If there are no frames at all, don't add one
+       *       -> If there are no strokes in that frame, don't add a new empty frame
+       */
       if (gpl->actframe && gpl->actframe->strokes.first) {
+        if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
+          gpl->actframe = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_COPY);
+        }
         has_layer_to_erase = true;
         break;
       }
     }
 
+    /* Ensure this gets set. */
+    if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
+      p->gpf = p->gpl->actframe;
+    }
+
     if (has_layer_to_erase == false) {
       p->status = GP_STATUS_ERROR;
       return;



More information about the Bf-blender-cvs mailing list