[Bf-blender-cvs] [1c58439bef8] greasepencil-object: Save Simplify flags at drawing start

Antonio Vazquez noreply at git.blender.org
Thu Mar 15 17:28:26 CET 2018


Commit: 1c58439bef80a25d5642ad13fa0ab7b66bfb5962
Author: Antonio Vazquez
Date:   Thu Mar 15 17:24:31 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB1c58439bef80a25d5642ad13fa0ab7b66bfb5962

Save Simplify flags at drawing start

As the simplify can change during play, the cache was not initializated and could get an error.

Saving the flags at the start solves this issue and improve the play animation in few mseconds.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h

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

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 013014bf008..7e59e49d962 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -734,7 +734,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 
 	/* apply geometry modifiers */
 	if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
-		if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+		if (!stl->storage->simplify_modif) {
 			if (BKE_gpencil_has_geometry_modifiers(ob)) {
 				BKE_gpencil_geometry_modifiers(&eval_ctx, ob, gpl, derived_gpf, stl->storage->is_render);
 			}
@@ -765,7 +765,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 		}
 
 		/* if the fill has any value, it's considered a fill and is not drawn if simplify fill is enabled */
-		if ((GP_SIMPLIFY_FILL(ts, playing)) && (ts->gpencil_simplify & GP_TOOL_FLAG_SIMPLIFY_REMOVE_LINE)) {
+		if ((stl->storage->simplify_fill) && (ts->gpencil_simplify & GP_TOOL_FLAG_SIMPLIFY_REMOVE_LINE)) {
 			if ((gps->palcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || 
 			    (gps->palcolor->fill_style > FILL_STYLE_SOLID))
 			{
@@ -786,7 +786,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 		if ((gpl->actframe->framenum == derived_gpf->framenum) || (!is_multiedit) || ((gpd->flag & GP_DATA_STROKE_MULTIEDIT_LINES) == 0)) {
 			int id = stl->storage->shgroup_id;
 			if (gps->totpoints > 0) {
-				if ((gps->totpoints > 2) && (!GP_SIMPLIFY_FILL(ts, playing)) && 
+				if ((gps->totpoints > 2) && (!stl->storage->simplify_fill) &&
 					((gps->palcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gps->palcolor->fill_style > 0)) &&
 					((gps->flag & GP_STROKE_NOFILL) == 0))
 				{
@@ -813,13 +813,13 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 
 			/* apply modifiers (only modify geometry, but not create ) */
 			if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
-				if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+				if (!stl->storage->simplify_modif) {
 					BKE_gpencil_stroke_modifiers(&eval_ctx, ob, gpl, derived_gpf, gps, stl->storage->is_render);
 				}
 			}
 
 			/* fill */
-			if ((fillgrp) && (!GP_SIMPLIFY_FILL(ts, playing))) {
+			if ((fillgrp) && (!stl->storage->simplify_fill)) {
 				gpencil_add_fill_shgroup(cache, fillgrp, ob, gpd, gpl, derived_gpf, gps, tintcolor, false, custonion);
 			}
 			/* stroke */
@@ -1160,7 +1160,7 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
 	cache->cache_idx = 0;
 
 	/* init general modifiers data */
-	if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+	if (!stl->storage->simplify_modif) {
 		if ((cache->is_dirty) && (ob->modifiers.first)) {
 			BKE_gpencil_lattice_init(ob);
 		}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index d8b4a167fb3..6505e9c9607 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -297,6 +297,11 @@ static void GPENCIL_cache_init(void *vedata)
 		/* save render state */
 		stl->storage->is_render = DRW_state_is_image_render();
 
+		/* save simplify flags (can change while drawing, so it's better to save) */
+		stl->storage->simplify_fill = GP_SIMPLIFY_FILL(ts, stl->storage->playing);
+		stl->storage->simplify_modif = GP_SIMPLIFY_MODIF(ts, stl->storage->playing);
+		stl->storage->simplify_vfx = GP_SIMPLIFY_VFX(ts, stl->storage->playing);
+
 		/* save pixsize */
 		stl->storage->pixsize = DRW_viewport_pixelsize_get();
 		if ((!DRW_state_is_opengl_render()) && (stl->storage->is_render)) {
@@ -484,7 +489,7 @@ static void GPENCIL_cache_populate(void *vedata, Object *ob)
 			/* generate instances as separate cache objects for array modifiers 
 			 * with the "Make as Objects" option enabled
 			 */
-			if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+			if (!stl->storage->simplify_modif) {
 				gpencil_array_modifiers(stl, ob);
 			}
 		}
@@ -533,7 +538,7 @@ static void GPENCIL_cache_finish(void *vedata)
 					stl->g_data->gp_object_cache[i].init_grp, stl->g_data->gp_object_cache[i].end_grp);
 			}
 			/* VFX pass */
-			if (!GP_SIMPLIFY_VFX(ts, playing)) {
+			if (!stl->storage->simplify_vfx) {
 				cache = &stl->g_data->gp_object_cache[i];
 				if ((!is_multiedit) && (ob->modifiers.first)) {
 					DRW_gpencil_vfx_modifiers(i, &e_data, vedata, ob, cache);
@@ -807,7 +812,7 @@ static void GPENCIL_draw_scene(void *vedata)
 				/* vfx modifiers passes
 				 * if any vfx modifier exist, the init_vfx_wave_sh will be not NULL.
 				 */
-				if ((cache->vfx_wave_sh) && (!GP_SIMPLIFY_VFX(ts, playing))) {
+				if ((cache->vfx_wave_sh) && (!stl->storage->simplify_vfx)) {
 					/* add vfx passes */
 					gpencil_vfx_passes(vedata, cache);
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 9c6f69c21ba..6f1d274b887 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -173,6 +173,11 @@ typedef struct GPENCIL_Storage {
 	float render_pixsize;
 	int tonemapping;
 
+	/* simplify settings*/
+	bool simplify_fill;
+	bool simplify_modif;
+	bool simplify_vfx;
+
 	/* Render Matrices and data */
 	float persmat[4][4], persinv[4][4];
 	float viewmat[4][4], viewinv[4][4];



More information about the Bf-blender-cvs mailing list