[Bf-blender-cvs] [d31de4f4908] greasepencil-object: New Onion skinning for select frames only

Antonio Vazquez noreply at git.blender.org
Sat Aug 19 22:57:36 CEST 2017


Commit: d31de4f4908c23cd77f3f50bf51bd14fc1c82d88
Author: Antonio Vazquez
Date:   Sat Aug 19 22:55:54 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBd31de4f4908c23cd77f3f50bf51bd14fc1c82d88

New Onion skinning for select frames only

Add an option to display only the frames selected in dopesheet.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.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 dd8ed4186d7..520fea615c5 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -1192,14 +1192,24 @@ class GreasePencilOnionPanel:
         row = sub.row(align=True)
         row.active = gpl.use_ghost_custom_colors
         row.prop(gpl, "before_color", text="")
-        sub.prop(gpl, "ghost_before_range", text="Before")
+
+        row = sub.row(align=True)
+        row.active = not gpl.onion_only_selected
+        row.prop(gpl, "ghost_before_range", text="Before")
 
         # - After Frames
         sub = split.column(align=True)
         row = sub.row(align=True)
         row.active = gpl.use_ghost_custom_colors
         row.prop(gpl, "after_color", text="")
-        sub.prop(gpl, "ghost_after_range", text="After")
+
+        row = sub.row(align=True)
+        row.active = not gpl.onion_only_selected
+        row.prop(gpl, "ghost_after_range", text="After")
+
+        row = layout.row(align=True)
+        row.active = gpl.use_onion_skinning
+        row.prop(gpl, "onion_only_selected", text="Only selected frames")
 
 
 class GreasePencilParentLayerPanel:
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index a5a5fba8be1..2f7f5e1ec68 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -155,7 +155,8 @@ class VIEW3D_HT_header(Header):
                 row.operator("gpencil.paste", text="", icon='PASTEDOWN')
 
             # XXX: icon
-            layout.prop(context.gpencil_data, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')
+            gpl = context.active_gpencil_layer
+            layout.prop(gpl, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')
 
             if context.gpencil_data.use_stroke_edit_mode or context.gpencil_data.is_stroke_sculpt_mode:
                 row = layout.row(align=True)
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 1340d0de2e2..32df4143ff1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -789,6 +789,7 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	const float default_color[3] = { UNPACK3(U.gpencil_new_layer_col) };
 	const float alpha = 1.0f;
 	float color[4];
+	bool selected = (bool)(gpl->flag & GP_LAYER_ONION_SELECTED);
 
 	/* 1) Draw Previous Frames First */
 	if (gpl->flag & GP_LAYER_GHOST_PREVCOL) {
@@ -798,14 +799,28 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 		copy_v3_v3(color, default_color);
 	}
 
-	if (gpl->gstep > 0) {
+	if ((gpl->gstep > 0) || (selected)) {
 		/* draw previous frames first */
 		for (bGPDframe *gf = gpf->prev; gf; gf = gf->prev) {
+			/* only selected frames */
+			if ((selected) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+				continue;
+			}
+			if (gf == gpl->actframe) {
+				continue;
+			}
+
 			/* check if frame is drawable */
-			if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
+			if (((gpf->framenum - gf->framenum) <= gpl->gstep) || (selected)) {
 				/* alpha decreases with distance from curframe index */
-				float fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
-				color[3] = alpha * fac * 0.66f;
+				if (!selected) {
+					float fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
+					color[3] = alpha * fac * 0.66f;
+				}
+				else {
+					color[3] = 0.66f;
+				}
+				BKE_gpencil_batch_cache_dirty(gpd);
 				gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gf, gf, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_PREVCOL);
 			}
 			else
@@ -816,6 +831,7 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 		/* draw the strokes for the ghost frames (at half of the alpha set by user) */
 		if (gpf->prev) {
 			color[3] = alpha * 0.7f;
+			BKE_gpencil_batch_cache_dirty(gpd);
 			gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf->prev, gpf->prev, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_PREVCOL);
 		}
 	}
@@ -831,14 +847,27 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 		copy_v3_v3(color, default_color);
 	}
 
-	if (gpl->gstep_next > 0) {
+	if ((gpl->gstep_next > 0) || (selected)) {
 		/* now draw next frames */
 		for (bGPDframe *gf = gpf->next; gf; gf = gf->next) {
+			/* only selected frames */
+			if ((selected) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+				continue;
+			}
+			if (gf == gpl->actframe) {
+				continue;
+			}
 			/* check if frame is drawable */
-			if ((gf->framenum - gpf->framenum) <= gpl->gstep_next) {
-				/* alpha decreases with distance from curframe index */
-				float fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
-				color[3] = alpha * fac * 0.66f;
+			if (((gf->framenum - gpf->framenum) <= gpl->gstep_next) || (selected)) {
+				if (!selected) {
+					/* alpha decreases with distance from curframe index */
+					float fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
+					color[3] = alpha * fac * 0.66f;
+				}
+				else {
+					color[3] = 0.66f;
+				}
+				BKE_gpencil_batch_cache_dirty(gpd);
 				gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gf, gf, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_NEXTCOL);
 			}
 			else
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index f5bb996ac8d..e147ae97fc5 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -301,6 +301,9 @@ typedef enum eGPDlayer_Flag {
 	GP_LAYER_GHOST_ALWAYS	= (1 << 13),
 	/* draw new strokes using last stroke location (only in 3d view) */
 	GP_LAYER_USE_LOCATION = (1 << 14),
+	/* only onion of selected frames */
+	GP_LAYER_ONION_SELECTED = (1 << 15),
+
 } eGPDlayer_Flag;
 
 /* xray modes */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index aaee530a4ab..4cbf6b5fa30 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1133,6 +1133,11 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Is Parented", "True when the layer parent object is set");
 
+	prop = RNA_def_property(srna, "onion_only_selected", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ONION_SELECTED);
+	RNA_def_property_ui_text(prop, "Onion Selected", "Show onion for selected frames only");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
 	/* Layers API */
 	func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
 	RNA_def_function_ui_description(func, "Remove all the grease pencil layer data");



More information about the Bf-blender-cvs mailing list