[Bf-blender-cvs] [3884b869277] blender2.8: Fix T56266: Second try to fix material problems

Antonioya noreply at git.blender.org
Tue Aug 7 22:13:37 CEST 2018


Commit: 3884b86927747a2662d0852d6d57c043c37d8cb4
Author: Antonioya
Date:   Tue Aug 7 22:13:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3884b86927747a2662d0852d6d57c043c37d8cb4

Fix T56266: Second try to fix material problems

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

M	source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
M	source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
index 155de7305b7..b47987ddbc0 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
@@ -135,8 +135,8 @@ static void bakeModifier(
 
 						assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
 
-						copy_v3_v3(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
-						copy_v3_v3(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
+						copy_v4_v4(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
+						copy_v4_v4(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
 
 						BLI_ghash_insert(gh_color, mat->id.name, newmat);
 						DEG_id_tag_update(&newmat->id, DEG_TAG_COPY_ON_WRITE);
@@ -146,9 +146,18 @@ static void bakeModifier(
 					gps->mat_nr = idx - 1;
 				}
 				else {
-					/* reuse existing color */
-					copy_v3_v3(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
-					copy_v3_v3(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
+					/* reuse existing color (but update only first time) */
+					if (BLI_ghash_lookup(gh_color, mat->id.name) == NULL) {
+						copy_v4_v4(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
+						copy_v4_v4(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
+						BLI_ghash_insert(gh_color, mat->id.name, mat);
+					}
+					/* update previews (icon and thumbnail) */
+					if (mat->preview != NULL) {
+						mat->preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED;
+						mat->preview->flag[ICON_SIZE_PREVIEW] |= PRV_CHANGED;
+					}
+					DEG_id_tag_update(&mat->id, DEG_TAG_COPY_ON_WRITE);
 				}
 
 			}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index e937f6454c2..8e2e97abf84 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -143,8 +143,8 @@ static void bakeModifier(
 
 						assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
 
-						copy_v3_v3(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
-						copy_v3_v3(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
+						copy_v4_v4(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
+						copy_v4_v4(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
 
 						BLI_ghash_insert(gh_color, mat->id.name, newmat);
 						DEG_id_tag_update(&newmat->id, DEG_TAG_COPY_ON_WRITE);
@@ -154,9 +154,18 @@ static void bakeModifier(
 					gps->mat_nr = idx - 1;
 				}
 				else {
-					/* reuse existing color */
-					copy_v3_v3(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
-					copy_v3_v3(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
+					/* reuse existing color (but update only first time) */
+					if (BLI_ghash_lookup(gh_color, mat->id.name) == NULL) {
+						copy_v4_v4(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba);
+						copy_v4_v4(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
+						BLI_ghash_insert(gh_color, mat->id.name, mat);
+					}
+					/* update previews (icon and thumbnail) */
+					if (mat->preview != NULL) {
+						mat->preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED;
+						mat->preview->flag[ICON_SIZE_PREVIEW] |= PRV_CHANGED;
+					}
+					DEG_id_tag_update(&mat->id, DEG_TAG_COPY_ON_WRITE);
 				}
 			}
 		}



More information about the Bf-blender-cvs mailing list