[Bf-blender-cvs] [2cdd34e] GPencil_Editing_Stage3: GPencil Drawing Usability: "Additive Drawing"

Joshua Leung noreply at git.blender.org
Sun Dec 6 14:30:07 CET 2015


Commit: 2cdd34eb8c0641fbe3be99695463e3db307a5f8f
Author: Joshua Leung
Date:   Mon Dec 7 02:21:29 2015 +1300
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rB2cdd34eb8c0641fbe3be99695463e3db307a5f8f

GPencil Drawing Usability: "Additive Drawing"

This commit adds a new option which will make it easier to use the Grease Pencil
drawing tools for animation. With the "Additive Drawing" option enabled in the
toolshelf (located alongside the "Continuous Drawing" toggle), the active frame's
strokes will be carried over/copied if you start drawing on an empty frame (i.e.
one without any keyframe already). This saves the effort of keeping a dopesshet
open, and to remember to duplicate the current frame before starting to draw the
next pose (or risk managing to draw the perfect pose, but without everything else).

Examples of cases where this comes in handy includes animating facial expressions
(when all outlines are on the same layer), or animating "growing" things (e.g. vines,
or concentric circles growing from a central point).

Note: Even without this option enabled, this is the default behaviour when using
the eraser on an "empty" frame. This makes it easier to do shots where you're just
changing parts of the facial expression, or if you're animating an "eraser" effect.

Note 2: The naming of this feature could do with some work. I struggled with several
alternative names for it, but this one seems the most useful about what it helps users
do. Suggestions welcome!

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 5dacfed..49af0e7 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -74,8 +74,8 @@ class GreasePencilDrawingToolsPanel:
         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
         row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
 
-        row = col.row(align=True)
-        row.prop(context.tool_settings, "use_grease_pencil_sessions", text="Continuous Drawing")
+        col.prop(context.tool_settings, "use_gpencil_additive_drawing", text="Additive Drawing")
+        col.prop(context.tool_settings, "use_gpencil_continuous_drawing", text="Continuous Drawing")
 
         if context.space_data.type in {'VIEW_3D', 'CLIP_EDITOR'}:
             col.separator()
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 4d13dd7..99fc195 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -57,9 +57,24 @@ struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd, bool internal_copy);
 
 void gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf);
 
+
+/* How gpencil_layer_getframe() should behave when there
+ * is no existing GP-Frame on the frame requested.
+ */
+typedef enum eGP_GetFrame_Mode {
+	/* Use the preceeding gp-frame (i.e. don't add anything) */
+	GP_GETFRAME_USE_PREV  = 0,
+	
+	/* Add a new empty/blank frame */
+	GP_GETFRAME_ADD_NEW   = 1,
+	/* Make a copy of the active frame */
+	GP_GETFRAME_ADD_COPY  = 2
+} eGP_GetFrame_Mode;
+
+struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew);
 struct bGPDframe *BKE_gpencil_layer_find_frame(struct bGPDlayer *gpl, int cframe);
-struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, short addnew);
 bool gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf);
+
 struct bGPDlayer *gpencil_layer_getactive(struct bGPdata *gpd);
 void gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
 void gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 4261054..e629a07 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -449,7 +449,7 @@ bGPDframe *BKE_gpencil_layer_find_frame(bGPDlayer *gpl, int cframe)
  *	- this sets the layer's actframe var (if allowed to)
  *	- extension beyond range (if first gp-frame is after all frame in interest and cannot add)
  */
-bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew)
+bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
 {
 	bGPDframe *gpf = NULL;
 	short found = 0;
@@ -487,6 +487,8 @@ bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew)
 			if (addnew) {
 				if ((found) && (gpf->framenum == cframe))
 					gpl->actframe = gpf;
+				else if (addnew == GP_GETFRAME_ADD_COPY)
+					gpl->actframe = gpencil_frame_addcopy(gpl, cframe);
 				else
 					gpl->actframe = gpencil_frame_addnew(gpl, cframe);
 			}
@@ -507,6 +509,8 @@ bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew)
 			if (addnew) {
 				if ((found) && (gpf->framenum == cframe))
 					gpl->actframe = gpf;
+				else if (addnew == GP_GETFRAME_ADD_COPY)
+					gpl->actframe = gpencil_frame_addcopy(gpl, cframe);
 				else
 					gpl->actframe = gpencil_frame_addnew(gpl, cframe);
 			}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index a724a27..c45fe1b 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1204,6 +1204,8 @@ static void gp_session_cleanup(tGPsdata *p)
 /* init new stroke */
 static void gp_paint_initstroke(tGPsdata *p, short paintmode)
 {
+	ToolSettings *ts = p->scene->toolsettings;
+	eGP_GetFrame_Mode add_frame_mode;
 	
 	/* get active layer (or add a new one if non-existent) */
 	p->gpl = gpencil_layer_getactive(p->gpd);
@@ -1221,15 +1223,22 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode)
 	}
 	
 	/* get active frame (add a new one if not matching frame) */
-	p->gpf = gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1);
+	if ((paintmode == GP_PAINTMODE_ERASER) || (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST))
+		add_frame_mode = GP_GETFRAME_ADD_COPY;
+	else
+		add_frame_mode = GP_GETFRAME_ADD_NEW;
+		
+	p->gpf = gpencil_layer_getframe(p->gpl, p->scene->r.cfra, add_frame_mode);
+	
 	if (p->gpf == NULL) {
 		p->status = GP_STATUS_ERROR;
 		if (G.debug & G_DEBUG)
 			printf("Error: No frame created (gpencil_paint_init)\n");
 		return;
 	}
-	else
+	else {
 		p->gpf->flag |= GP_FRAME_PAINT;
+	}
 	
 	/* set 'eraser' for this stroke if using eraser */
 	p->paintmode = paintmode;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index fb80895..ed7f922 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2277,12 +2277,19 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
 	/* Grease Pencil */
-	prop = RNA_def_property(srna, "use_grease_pencil_sessions", PROP_BOOLEAN, PROP_NONE);
+	prop = RNA_def_property(srna, "use_gpencil_continuous_drawing", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON);
-	RNA_def_property_ui_text(prop, "Use Sketching Sessions",
+	RNA_def_property_ui_text(prop, "Use Continuous Drawing",
 	                         "Allow drawing multiple strokes at a time with Grease Pencil");
 	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */
 	
+	prop = RNA_def_property(srna, "use_gpencil_additive_drawing", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_RETAIN_LAST);
+	RNA_def_property_ui_text(prop, "Use Additive Drawing",
+	                         "When creating new frames, the strokes from the previous/active frame "
+	                         "are included as the basis for the new one");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+	
 	prop = RNA_def_property(srna, "grease_pencil_source", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_src");
 	RNA_def_property_enum_items(prop, gpencil_source_3d_items);




More information about the Bf-blender-cvs mailing list