[Bf-blender-cvs] [0eb7227e3cd] greasepencil-object: Remove Previous/Next mode in Onion Skinning

Antonio Vazquez noreply at git.blender.org
Tue Aug 22 20:13:24 CEST 2017


Commit: 0eb7227e3cd98b9df8c946c7638980ae987ca4c1
Author: Antonio Vazquez
Date:   Tue Aug 22 20:08:31 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB0eb7227e3cd98b9df8c946c7638980ae987ca4c1

Remove Previous/Next mode in Onion Skinning

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

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/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 3bb0dede7b4..12597801aba 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -783,7 +783,7 @@ void DRW_gpencil_populate_buffer_strokes(void *vedata, ToolSettings *ts, bGPdata
 }
 
 /* draw onion-skinning for a layer */
-static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_data, void *vedata, 
+static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_data, void *vedata,
 	ToolSettings *ts, Object *ob, bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf)
 {
 	const float default_color[3] = { UNPACK3(U.gpencil_new_layer_col) };
@@ -793,7 +793,7 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	float fac = 1.0f;
 
 	/* -------------------------------
-	 * 1) Draw Previous Frames First 
+	 * 1) Draw Previous Frames First
 	 * ------------------------------- */
 	if (gpl->flag & GP_LAYER_GHOST_PREVCOL) {
 		copy_v3_v3(color, gpl->gcolor_prev);
@@ -802,55 +802,46 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 		copy_v3_v3(color, default_color);
 	}
 
-	if (gpl->onion_mode != GP_ONION_MODE_ZERO) {
-		idx = 0;
-		for (bGPDframe *gf = gpf->prev; gf; gf = gf->prev) {
-			/* only selected frames */
-			if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
-				continue;
+	idx = 0;
+	for (bGPDframe *gf = gpf->prev; gf; gf = gf->prev) {
+		/* only selected frames */
+		if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+			continue;
+		}
+		/* absolute range */
+		if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+			if ((gpf->framenum - gf->framenum) > gpl->gstep) {
+				break;
 			}
-			/* absolute range */
-			if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-				if ((gpf->framenum - gf->framenum) > gpl->gstep) {
-					continue;
-				}
+		}
+		/* relative range */
+		if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
+			++idx;
+			if (idx > gpl->gstep) {
+				break;
 			}
-			/* relative range */
-			if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
-				++idx;
-				if (idx > gpl->gstep) {
-					continue;
-				}
 
-			}
-			/* alpha decreases with distance from curframe index */
-			if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
-				if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-					fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
-				}
-				else {
-					fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
-				}
-				color[3] = alpha * fac * 0.66f;
+		}
+		/* alpha decreases with distance from curframe index */
+		if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
+			if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+				fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
 			}
 			else {
-				color[3] = 0.66f;
+				fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
 			}
-			CLAMP_MIN(color[3], 0.66f);
-			/* draw */
-			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);
+			color[3] = alpha * fac * 0.66f;
 		}
-	}
-	else {
-		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);
+		else {
+			color[3] = 0.66f;
 		}
+		CLAMP_MIN(color[3], 0.66f);
+		/* draw */
+		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);
 	}
 	/* -------------------------------
-	 * 2) Now draw next frames 
+	 * 2) Now draw next frames
 	 * ------------------------------- */
 	if (gpl->flag & GP_LAYER_GHOST_NEXTCOL) {
 		copy_v3_v3(color, gpl->gcolor_next);
@@ -859,50 +850,42 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 		copy_v3_v3(color, default_color);
 	}
 
-	if (gpl->onion_mode != GP_ONION_MODE_ZERO) {
-		idx = 0;
-		for (bGPDframe *gf = gpf->next; gf; gf = gf->next) {
-			/* only selected frames */
-			if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
-				continue;
+	idx = 0;
+	for (bGPDframe *gf = gpf->next; gf; gf = gf->next) {
+		/* only selected frames */
+		if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+			continue;
+		}
+		/* absolute range */
+		if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+			if ((gf->framenum - gpf->framenum) > gpl->gstep_next) {
+				break;
 			}
-			/* absolute range */
-			if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-				if ((gf->framenum - gpf->framenum) > gpl->gstep_next) {
-					continue;
-				}
+		}
+		/* relative range */
+		if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
+			++idx;
+			if (idx > gpl->gstep_next) {
+				break;
 			}
-			/* relative range */
-			if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
-				++idx;
-				if (idx > gpl->gstep) {
-					continue;
-				}
 
-			}
-			/* alpha decreases with distance from curframe index */
-			if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
-				if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-					fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
-				}
-				else {
-					fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
-				}
-				color[3] = alpha * fac * 0.66f;
+		}
+		/* alpha decreases with distance from curframe index */
+		if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
+			if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+				fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
 			}
 			else {
-				color[3] = 0.66f;
+				fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
 			}
-			CLAMP_MIN(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);
+			color[3] = alpha * fac * 0.66f;
 		}
-	}
-	else {
-		if (gpf->next) {
-			color[3] = alpha * 0.7f;
-			gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf->next, gpf->next, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_NEXTCOL);
+		else {
+			color[3] = 0.66f;
 		}
+		CLAMP_MIN(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);
 	}
 }
 
@@ -916,6 +899,9 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
 		printf("DRW_gpencil_populate_datablock: %s\n", gpd->id.name);
 	}
 
+	/* TODO: check if playing animation */
+	bool playing = false;
+
 	GpencilBatchCache *cache = gpencil_batch_cache_get(ob, CFRA);
 	cache->cache_idx = 0;
 
@@ -953,7 +939,8 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
 		}
 
 		/* draw onion skins */
-		if ((gpl->flag & GP_LAYER_ONIONSKIN) || (gpl->flag & GP_LAYER_GHOST_ALWAYS))
+		if ((gpl->flag & GP_LAYER_ONIONSKIN) &&
+			((!playing) || (gpl->flag & GP_LAYER_GHOST_ALWAYS)))
 		{
 			gpencil_draw_onionskins(cache, e_data, vedata, ts, ob, gpd, gpl, derived_gpf);
 		}
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index c504781a263..ea5d9f54caa 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -314,10 +314,9 @@ typedef enum eGP_Xraymodes_Types {
 
 /* onion modes */
 typedef enum eGP_onion_modes_Types {
-	GP_ONION_MODE_ZERO     = 0,
-	GP_ONION_MODE_ABSOLUTE = 1,
-	GP_ONION_MODE_RELATIVE = 2,
-	GP_ONION_MODE_SELECTED = 3,
+	GP_ONION_MODE_ABSOLUTE = 0,
+	GP_ONION_MODE_RELATIVE = 1,
+	GP_ONION_MODE_SELECTED = 2,
 } eGP_onion_modes_Types;
 
 /* Grease-Pencil Annotations - 'DataBlock' */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index be26bb547b3..fcb945d5620 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -63,7 +63,6 @@ static EnumPropertyItem rna_enum_gpencil_xraymodes_items[] = {
 };
 
 static EnumPropertyItem rna_enum_gpencil_onion_modes_items[] = {
-	{ GP_ONION_MODE_ZERO, "ZERO", 0, "Previous/Next", "Previous and Next frame" },
 	{ GP_ONION_MODE_ABSOLUTE, "ABSOLUTE", 0, "Frames", "Frames in absolute range of scene frame number" },
 	{ GP_ONION_MODE_RELATIVE, "RELATIVE", 0, "Keyframes", "Frames in relative range of grease pencil keyframes" },
 	{ GP_ONION_MODE_SELECTED, "SELECTED", 0, "Selected", "Only Selected Frames" },
@@ -1005,18 +1004,18 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	
 	prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "gstep");
-	RNA_def_property_range(prop, -1, 120);
+	RNA_def_property_range(prop, 0, 120);
 	RNA_def_property_ui_text(prop, "Frames Before",
 	                         "Maximum number of frames to show before current frame "
-	                         "(0 = show only the previous sketch, -1 = don't show any frames before current)");
+	                         "(0 = don't show any frames before current)");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 	
 	prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "gstep_next");
-	RNA_def_property_range(prop, -1, 120);
+	RNA_def_property_range(prop, 0, 120);
 	RNA_def_property_ui_text(prop, "Frames After",
 	                         "Maximum number of frames to show after current frame "
-	                         "(0 = show only the next sketch, -1 = don't show any frames after current)");
+	                         "(0 = don't show any frames after current)");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 	
 	prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_B

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list