[Bf-blender-cvs] [89553287192] greasepencil-object: Add override options for onion skinning

Antonio Vazquez noreply at git.blender.org
Fri Sep 15 17:20:14 CEST 2017


Commit: 89553287192562c82dac89070bdc1866da1106aa
Author: Antonio Vazquez
Date:   Fri Sep 15 17:19:56 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB89553287192562c82dac89070bdc1866da1106aa

Add override options for onion skinning

This commit add options to modify at layer level the default onion skinning parameters defined at object level.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/editors/gpencil/drawgpencil.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 7f81e7e721f..9e8c6e07a31 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -1228,6 +1228,7 @@ class GreasePencilOnionPanel:
     def draw(self, context):
         layout = self.layout
         gpd = context.gpencil_data
+        gpl = context.active_gpencil_layer
 
         col = layout.column(align=True)
 
@@ -1238,7 +1239,7 @@ class GreasePencilOnionPanel:
         sub.prop(gpd, "use_ghosts_always", text="", icon=icon)
         sub.prop(gpd, "use_ghost_custom_colors", text="", icon='COLOR')
 
-        split = col.split(percentage=0.5)
+        split = layout.split(percentage=0.5)
         split.active = gpd.use_onion_skinning
 
         # - Before Frames
@@ -1273,6 +1274,59 @@ class GreasePencilOnionPanel:
         sub = split.column(align=True)
         sub.prop(gpd, "onion_factor", text="Opacity", slider=True)
 
+        # -----------------
+        # layer override
+        # -----------------
+        ovr = gpd.use_onion_skinning and gpl.override_onion
+        layout.separator()
+        box = layout.box()
+        col = box.column(align=True)
+        col.active = gpd.use_onion_skinning
+
+        row = col.row()
+        row.prop(gpl, "override_onion", text="Override Layer")
+        if gpl.override_onion:
+            sub = row.row(align=True)
+            icon = 'RESTRICT_RENDER_OFF' if gpd.use_ghosts_always else 'RESTRICT_RENDER_ON'
+            sub.prop(gpl, "use_ghosts_always", text="", icon=icon)
+            sub.prop(gpl, "use_ghost_custom_colors", text="", icon='COLOR')
+
+
+            split = box.split(percentage=0.5)
+            split.active = ovr
+
+            # - Before Frames
+            sub = split.column(align=True)
+            row = sub.row(align=True)
+            row.active = gpl.use_ghost_custom_colors
+            row.prop(gpl, "before_color", text="")
+
+            # - 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="")
+
+            split = box.split(percentage=0.5)
+            split.active = gpl.onion_mode in ('ABSOLUTE', 'RELATIVE')
+            sub = split.column(align=True)
+            sub.prop(gpl, "ghost_before_range", text="Before")
+
+            sub = split.column(align=True)
+            sub.prop(gpl, "ghost_after_range", text="After")
+
+            row = box.row(align=True)
+            row.active = ovr
+            row.prop(gpl, "onion_mode", text="Mode")
+
+            split = box.split(percentage=0.5)
+            split.active = ovr
+            sub = split.column(align=True)
+            sub.prop(gpl, "use_onion_fade", text="Fade")
+
+            sub = split.column(align=True)
+            sub.prop(gpl, "onion_factor", text="Opacity", slider=True)
+
 
 class GreasePencilParentLayerPanel:
     bl_label = "Parent Layer"
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 97b90387c61..f4dfaa57720 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -461,8 +461,14 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
 	gpl->opacity = 1.0f;
 
 	/* onion-skinning settings */
-	gpl->flag |= GP_LAYER_ONIONSKIN;
-	
+	gpl->onion_flag |= GP_LAYER_ONIONSKIN;
+	gpl->onion_flag |= (GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL);
+	gpl->onion_flag |= GP_LAYER_ONION_FADE;
+	gpl->onion_factor = 0.5f;
+
+	ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */
+	ARRAY_SET_ITEMS(gpl->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */
+
 	/* auto-name */
 	BLI_strncpy(gpl->info, name, sizeof(gpl->info));
 	BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
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 8221115a13f..eb9affd37c8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -844,44 +844,62 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	float color[4];
 	int idx;
 	float fac = 1.0f;
+	int step = 0;
+	int mode = 0;
 
 	/* -------------------------------
 	 * 1) Draw Previous Frames First
 	 * ------------------------------- */
-	if (gpd->onion_flag & GP_ONION_GHOST_PREVCOL) {
-		copy_v3_v3(color, gpd->gcolor_prev);
+	if (gpl->onion_flag & GP_LAYER_ONION_OVERRIDE) {
+		step = gpl->gstep;
+		mode = gpl->onion_mode;
+
+		if (gpl->onion_flag & GP_LAYER_GHOST_PREVCOL) {
+			copy_v3_v3(color, gpl->gcolor_prev);
+		}
+		else {
+			copy_v3_v3(color, default_color);
+		}
 	}
 	else {
-		copy_v3_v3(color, default_color);
+		step = gpd->gstep;
+		mode = gpd->onion_mode;
+
+		if (gpd->onion_flag & GP_ONION_GHOST_PREVCOL) {
+			copy_v3_v3(color, gpd->gcolor_prev);
+		}
+		else {
+			copy_v3_v3(color, default_color);
+		}
 	}
 
 	idx = 0;
 	for (bGPDframe *gf = gpf->prev; gf; gf = gf->prev) {
 		/* only selected frames */
-		if ((gpd->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+		if ((mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
 			continue;
 		}
 		/* absolute range */
-		if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-			if ((gpf->framenum - gf->framenum) > gpd->gstep) {
+		if (mode == GP_ONION_MODE_ABSOLUTE) {
+			if ((gpf->framenum - gf->framenum) > step) {
 				break;
 			}
 		}
 		/* relative range */
-		if (gpd->onion_mode == GP_ONION_MODE_RELATIVE) {
+		if (mode == GP_ONION_MODE_RELATIVE) {
 			++idx;
-			if (idx > gpd->gstep) {
+			if (idx > step) {
 				break;
 			}
 
 		}
 		/* alpha decreases with distance from curframe index */
-		if (gpd->onion_mode != GP_ONION_MODE_SELECTED) {
-			if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-				fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpd->gstep + 1));
+		if (mode != GP_ONION_MODE_SELECTED) {
+			if (mode == GP_ONION_MODE_ABSOLUTE) {
+				fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(step + 1));
 			}
 			else {
-				fac = 1.0f - ((float)idx / (float)(gpd->gstep + 1));
+				fac = 1.0f - ((float)idx / (float)(step + 1));
 			}
 			color[3] = alpha * fac * 0.66f;
 		}
@@ -891,11 +909,20 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 			color[3] = fac;
 		}
 		/* if fade is disabled, opacity is equal in all frames */
-		if ((gpd->onion_flag & GP_ONION_FADE) == 0) {
-			color[3] = 0.66f;
+		if (gpl->onion_flag & GP_LAYER_ONION_OVERRIDE) {
+			if ((gpl->onion_flag & GP_LAYER_ONION_FADE) == 0) {
+				color[3] = 0.66f;
+			}
+			/* add override opacity factor */
+			color[3] += gpl->onion_factor - 0.5f;
+		}
+		else {
+			if ((gpd->onion_flag & GP_ONION_FADE) == 0) {
+				color[3] = 0.66f;
+			}
+			/* add override opacity factor */
+			color[3] += gpd->onion_factor - 0.5f;
 		}
-		/* add override opacity factor */
-		color[3] += gpd->onion_factor - 0.5f;
 
 		CLAMP(color[3], 0.3f, 1.0f);
 		gpencil_draw_onion_strokes(cache, e_data, vedata, ob, gpd, gpl, gf, color, gpd->onion_flag & GP_ONION_GHOST_PREVCOL);
@@ -903,40 +930,56 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	/* -------------------------------
 	 * 2) Now draw next frames
 	 * ------------------------------- */
-	if (gpd->onion_flag & GP_ONION_GHOST_NEXTCOL) {
-		copy_v3_v3(color, gpd->gcolor_next);
+	if (gpl->onion_flag & GP_LAYER_ONION_OVERRIDE) {
+		step = gpl->gstep_next;
+		mode = gpl->onion_mode;
+
+		if (gpl->onion_flag & GP_LAYER_GHOST_NEXTCOL) {
+			copy_v3_v3(color, gpl->gcolor_next);
+		}
+		else {
+			copy_v3_v3(color, default_color);
+		}
 	}
 	else {
-		copy_v3_v3(color, default_color);
+		step = gpd->gstep_next;
+		mode = gpd->onion_mode;
+
+		if (gpd->onion_flag & GP_ONION_GHOST_NEXTCOL) {
+			copy_v3_v3(color, gpd->gcolor_next);
+		}
+		else {
+			copy_v3_v3(color, default_color);
+		}
 	}
 
 	idx = 0;
 	for (bGPDframe *gf = gpf->next; gf; gf = gf->next) {
 		/* only selected frames */
-		if ((gpd->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+		if ((mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
 			continue;
 		}
 		/* absolute range */
-		if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-			if ((gf->framenum - gpf->framenum) > gpd->gstep_next) {
+		if (mode == GP_ONION_MODE_ABSOLUTE) {
+			if ((gf->framenum - gpf->framenum) >step) {
 				break;
 			}
 		}
 		/* relative range */
-		if (gpd->onion_mode == GP_ONION_MODE_RELATIVE) {
+		if (mode == GP_ONION_MODE_RELATIVE) {
 			++idx;
-			if (idx > gpd->gstep_next) {
+			if (idx > step) {
 				break;
 			}
 
 		}
 		/* alpha decreases with distance from curframe index */
-		if (gpd->onion_mode != GP_ONION_MODE_SELECTED) {
-			if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-				fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpd->gstep_next + 1));
+		if (mode != GP_ONION_MODE_SELECTED) {
+			if (mode == GP_ONION_MODE_ABSOLUTE) {
+				fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(step + 1));
 			}
 			else {
-				fac = 1.0f - ((float)idx / (float)(gpd->gstep + 1));
+				fac = 1.0f - ((float)idx / (float)(step + 1));
 			}
 			color[3] = alpha * fac * 0.66f;
 		}
@@ -946,11 +989,20 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 			color[3] = fac;
 		}
 		/* if fade is disabled, opacity is equal in all frames */
-		if ((gpd->onion_flag & GP_ONION_FADE) == 0) {
-			color[3] = 0.66f;
+		if (gpl->onion_flag & GP_LAYER_ONION_OVERRIDE) {
+			if ((gpl->onion_flag & GP_ONION_FADE) == 0) {
+				color[3] = 0.66f;
+			}
+			/* add override opacity factor */
+			color[3] += gpl->onion_factor - 0.5f;
+		}
+		else {
+			if ((gpd->onion_flag & GP_ONION_FADE) == 0) {
+				color[3] = 0.66f;
+			}
+			/* add overr

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list