diff options
4 files changed, 31 insertions, 18 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 7eeb45cc52e..3a1801f2a53 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -1756,7 +1756,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT") row = layout.row() - row.prop(md, "create_colors") + row.prop(md, "create_materials") def GP_COLOR(self, layout, ob, md): gpd = ob.data @@ -1778,7 +1778,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT") row = layout.row() - row.prop(md, "create_colors") + row.prop(md, "create_materials") def GP_OPACITY(self, layout, ob, md): gpd = ob.data 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); } } } diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 8c4edf8030c..1bfcf415a94 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -681,9 +681,9 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Factor", "Factor for mixing color"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); - prop = RNA_def_property(srna, "create_colors", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "create_materials", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_CREATE_COLORS); - RNA_def_property_ui_text(prop, "Create Colors", "When apply modifier, create new color in the palette"); + RNA_def_property_ui_text(prop, "Create Materials", "When apply modifier, create new material"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); @@ -739,9 +739,9 @@ static void rna_def_modifier_gpencilcolor(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Value", "Color Value"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); - prop = RNA_def_property(srna, "create_colors", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "create_materials", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_COLOR_CREATE_COLORS); - RNA_def_property_ui_text(prop, "Create Colors", "When apply modifier, create new color in the palette"); + RNA_def_property_ui_text(prop, "Create Materials", "When apply modifier, create new material"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); |