[Bf-blender-cvs] [cca1d1038f0] greasepencil-object: Fix problem with preview for not visible materials

Antonio Vazquez noreply at git.blender.org
Tue Jul 17 15:08:30 CEST 2018


Commit: cca1d1038f01e8d001492321c420639c2420bd75
Author: Antonio Vazquez
Date:   Tue Jul 17 15:08:19 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBcca1d1038f01e8d001492321c420639c2420bd75

Fix problem with preview for not visible materials

The preview must be generated with the color enabled and not checking the current scene settings. If we don't do this, the preview is empty for these materials.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_utils.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_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 3e3374bf9c4..5c3cadd6e91 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -63,12 +63,18 @@
 #define PATTERN 5
 
 /* Helper for doing all the checks on whether a stroke can be drawn */
-static bool gpencil_can_draw_stroke(struct MaterialGPencilStyle *gp_style, const bGPDstroke *gps, const bool onion)
+static bool gpencil_can_draw_stroke(struct MaterialGPencilStyle *gp_style, const bGPDstroke *gps,
+									const bool onion, const bool is_mat_preview)
 {
 	/* skip stroke if it doesn't have any valid data */
 	if ((gps->points == NULL) || (gps->totpoints < 1) || (gp_style == NULL))
 		return false;
 
+	/* if mat preview render always visible */
+	if (is_mat_preview) {
+		return true;
+	}
+
 	/* check if the color is visible */
 	if ((gp_style == NULL) ||
 		(gp_style->flag & GP_STYLE_COLOR_HIDE) ||
@@ -703,7 +709,7 @@ static void gpencil_draw_onion_strokes(
 
 		int id = stl->storage->shgroup_id;
 		/* check if stroke can be drawn */
-		if (gpencil_can_draw_stroke(gp_style, gps, true) == false) {
+		if (gpencil_can_draw_stroke(gp_style, gps, true, false) == false) {
 			continue;
 		}
 		/* limit the number of shading groups */
@@ -749,6 +755,7 @@ static void gpencil_draw_strokes(
 	const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
 	const bool playing = (bool)stl->storage->playing;
 	const bool is_render = (bool)stl->storage->is_render;
+	const bool is_mat_preview = (bool)stl->storage->is_mat_preview;
 	const bool overlay_multiedit = v3d != NULL ? (v3d->flag3 & V3D_GP_SHOW_MULTIEDIT_LINES) : true;
 
 	/* Get evaluation context */
@@ -781,7 +788,7 @@ static void gpencil_draw_strokes(
 		MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
 
 		/* check if stroke can be drawn */
-		if (gpencil_can_draw_stroke(gp_style, gps, false) == false) {
+		if (gpencil_can_draw_stroke(gp_style, gps, false, is_mat_preview) == false) {
 			continue;
 		}
 		/* limit the number of shading groups */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 91ab6b2ad3b..1db1bbb746e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -334,6 +334,7 @@ void GPENCIL_cache_init(void *vedata)
 
 		/* save render state */
 		stl->storage->is_render = DRW_state_is_image_render();
+		stl->storage->is_mat_preview = (bool)stl->storage->is_render && STREQ(scene->id.name + 2, "preview");
 
 		/* save simplify flags (can change while drawing, so it's better to save) */
 		stl->storage->simplify_fill = GP_SIMPLIFY_FILL(scene, stl->storage->playing);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 7895fd1c8a8..c57e4652988 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -106,6 +106,7 @@ typedef struct GPENCIL_Storage {
 	float pixfactor;
 	int playing;
 	bool is_render;
+	bool is_mat_preview;
 	int uselines;
 	float gridsize[2];
 	float gridcolor[3];



More information about the Bf-blender-cvs mailing list