diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-07 21:10:20 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-07 21:10:20 +0300 |
commit | 8a035612ee8bd361bf43c8935b03822cf1208435 (patch) | |
tree | f5d0d4b1227a888e9c4738b49d31f679f4aa10a8 /source/blender/gpencil_modifiers | |
parent | 035d827b5b132627d5ea73e3fa237d8fd2185b4f (diff) |
Fix T56266: Grease Pencil Tint and Color modifier error when apply
The material created was not right when apply the modifiers.
These errors were related to the material modification from old palette system before the merge and for any reason this code was not changed in the right way.
Also changed the "Create Colors" to "Create Materials" to keep UI names aligned.
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c | 19 | ||||
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c | 18 |
2 files changed, 25 insertions, 12 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c index 88754f29db3..155de7305b7 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c @@ -35,6 +35,8 @@ #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" +#include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_math_color.h" @@ -120,18 +122,24 @@ static void bakeModifier( copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba); copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba); + deformStroke(md, depsgraph, ob, gpl, gps); + /* look for color */ - if (mmd->flag & GP_TINT_CREATE_COLORS) { + if (mmd->flag & GP_COLOR_CREATE_COLORS) { Material *newmat = BLI_ghash_lookup(gh_color, mat->id.name); if (newmat == NULL) { BKE_object_material_slot_add(bmain, ob); newmat = BKE_material_copy(bmain, mat); + newmat->gp_style = MEM_dupallocN(mat->gp_style); + newmat->preview = NULL; + assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF); - 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); + 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); BLI_ghash_insert(gh_color, mat->id.name, newmat); + DEG_id_tag_update(&newmat->id, DEG_TAG_COPY_ON_WRITE); } /* reasign color index */ int idx = BKE_object_material_slot_find_index(ob, newmat); @@ -139,11 +147,10 @@ static void bakeModifier( } else { /* reuse existing color */ - copy_v4_v4(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); - copy_v4_v4(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); + copy_v3_v3(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); + copy_v3_v3(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); } - deformStroke(md, depsgraph, ob, gpl, gps); } } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c index 641a75bc353..e937f6454c2 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c @@ -35,6 +35,8 @@ #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" +#include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_math_vector.h" @@ -128,18 +130,24 @@ static void bakeModifier( copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba); copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba); + deformStroke(md, depsgraph, ob, gpl, gps); + /* look for color */ if (mmd->flag & GP_TINT_CREATE_COLORS) { Material *newmat = (Material *)BLI_ghash_lookup(gh_color, mat->id.name); if (newmat == NULL) { BKE_object_material_slot_add(bmain, ob); newmat = BKE_material_copy(bmain, mat); + newmat->gp_style = MEM_dupallocN(mat->gp_style); + newmat->preview = NULL; + assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF); - 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); + 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); BLI_ghash_insert(gh_color, mat->id.name, newmat); + DEG_id_tag_update(&newmat->id, DEG_TAG_COPY_ON_WRITE); } /* reasign color index */ int idx = BKE_object_material_slot_find_index(ob, newmat); @@ -147,11 +155,9 @@ static void bakeModifier( } else { /* reuse existing color */ - copy_v4_v4(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); - copy_v4_v4(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); + copy_v3_v3(gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); + copy_v3_v3(gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); } - - deformStroke(md, depsgraph, ob, gpl, gps); } } } |