[Bf-blender-cvs] [19b066c41b1] greasepencil-object: GP: Enable Object Onion Skin by default

Antonioya noreply at git.blender.org
Mon Dec 10 10:46:08 CET 2018


Commit: 19b066c41b18ce90fcd7c5ce17901f01f020dcd3
Author: Antonioya
Date:   Mon Dec 10 10:41:47 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB19b066c41b18ce90fcd7c5ce17901f01f020dcd3

GP: Enable Object Onion Skin by default

Now, the main switchis on, and the layer onion skin is off.

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index dd1a2520991..2753a5adbaa 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -381,8 +381,6 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
 		/* thickness parameter represents "thickness change", not absolute thickness */
 		gpl->thickness = 0;
 		gpl->opacity = 1.0f;
-		/* onion-skinning settings */
-		gpl->onion_flag |= GP_LAYER_ONIONSKIN;
 	}
 
 	/* auto-name */
@@ -415,7 +413,8 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
 	/* general flags */
 	gpd->flag |= GP_DATA_VIEWALIGN;
 	gpd->flag |= GP_DATA_STROKE_FORCE_RECALC;
-
+	/* always enable object onion skin swith */
+	gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
 	/* GP object specific settings */
 	ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 5478c4a60b9..63af8ecc141 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -186,7 +186,7 @@ static bool gpencil_batch_cache_valid(GpencilBatchCache *cache, bGPdata *gpd, in
 	else if (gpd->flag & GP_DATA_CACHE_IS_DIRTY) {
 		valid = false;
 	}
-	else if (gpd->flag & GP_DATA_SHOW_ONIONSKINS) {
+	else if (DRW_gpencil_onion_active(gpd)) {
 		/* if onion, set as dirty always
 		 * This reduces performance, but avoid any crash in the multiple
 		 * overlay and multiwindow options and keep all windows working
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 9fe45bbaec0..ef2b31a3aaa 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -366,6 +366,20 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
 	return grp;
 }
 
+/* check if some onion is enabled */
+bool DRW_gpencil_onion_active(bGPdata *gpd)
+{
+	if ((gpd->flag & GP_DATA_SHOW_ONIONSKINS) == 0) {
+		return false;
+	}
+	for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+		if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
+			return true;
+		}
+	}
+	return false;
+}
+
 /* create shading group for strokes */
 DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
         GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader *shader, Object *ob,
@@ -1499,7 +1513,8 @@ void DRW_gpencil_populate_datablock(
 
 	bGPDframe *derived_gpf = NULL;
 	const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true;
-	const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion;
+	const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) &&
+		main_onion && DRW_gpencil_onion_active(gpd);
 	const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) : true;
 	const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
 
@@ -1585,8 +1600,7 @@ void DRW_gpencil_populate_datablock(
 
 		/* draw onion skins */
 		if (!ID_IS_LINKED(&gpd->id)) {
-			if ((gpd->flag & GP_DATA_SHOW_ONIONSKINS) &&
-			    (do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) &&
+			if ((do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) &&
 			    ((!playing) || (gpd->onion_flag & GP_ONION_GHOST_ALWAYS)) &&
 			    (!cache_ob->is_dup_ob) && (gpd->id.us <= 1))
 			{
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index b8b526cb873..4aaf81ea5fd 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -385,6 +385,8 @@ struct tGPencilObjectCache *gpencil_object_cache_add(
         struct tGPencilObjectCache *cache_array, struct Object *ob,
         int *gp_cache_size, int *gp_cache_used);
 
+bool DRW_gpencil_onion_active(struct bGPdata *gpd);
+
 /* shading groups cache functions */
 struct GpencilBatchGroup *gpencil_group_cache_add(
 	struct GpencilBatchGroup *cache_array,



More information about the Bf-blender-cvs mailing list