diff options
4 files changed, 28 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 803abe98055..843ab79a639 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -1880,6 +1880,9 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "pass_index", text="Pass") row.prop(md, "invert_pass", text="", icon='ARROW_LEFTRIGHT') + col.prop(md, "replace_material", text="Material") + col.prop(md, "keep_on_top", text="Keep original stroke on top") + def GP_BUILD(self, layout, ob, md): gpd = ob.data diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilinstance.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilinstance.c index 3f4183e5b7a..8c125ebb1cd 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilinstance.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilinstance.c @@ -180,6 +180,11 @@ static void generate_geometry( mul_m4_v3(mat, &pt->x); } + /* if replace material, use new one */ + if ((mmd->mat_rpl > 0) && (mmd->mat_rpl <= ob->totcol)) { + gps_dst->mat_nr = mmd->mat_rpl - 1; + } + /* Add new stroke to cache, to be added to the frame once * all duplicates have been made */ @@ -191,7 +196,12 @@ static void generate_geometry( } /* merge newly created stroke instances back into the main stroke list */ - BLI_movelisttolist(&gpf->strokes, &stroke_cache); + if (mmd->flag & GP_INSTANCE_KEEP_ONTOP) { + BLI_movelisttolist_reverse(&gpf->strokes, &stroke_cache); + } + else { + BLI_movelisttolist(&gpf->strokes, &stroke_cache); + } /* free temp data */ MEM_SAFE_FREE(valid_strokes); diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index ae341b24e41..26b3cf934d4 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -211,6 +211,8 @@ typedef struct InstanceGpencilModifierData { int pass_index; /* custom index for passes */ char layername[64]; /* layer name */ + int mat_rpl; /* material replace (0 keep default) */ + char pad[4]; } InstanceGpencilModifierData; typedef enum eInstanceGpencil_Flag { @@ -218,6 +220,7 @@ typedef enum eInstanceGpencil_Flag { GP_INSTANCE_RANDOM_ROT = (1 << 1), GP_INSTANCE_INVERT_LAYER = (1 << 2), GP_INSTANCE_INVERT_PASS = (1 << 3), + GP_INSTANCE_KEEP_ONTOP = (1 << 4), } eInstanceGpencil_Flag; typedef struct BuildGpencilModifierData { diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 4afd6c4172d..b45ef341187 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -922,6 +922,12 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna) RNA_def_property_range(prop, -10.0, 10.0); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "replace_material", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "mat_rpl"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Material", "Index of the material used for generated strokes (0 keep original material)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_INSTANCE_INVERT_LAYER); RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); @@ -932,6 +938,11 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "keep_on_top", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_INSTANCE_KEEP_ONTOP); + RNA_def_property_ui_text(prop, "Keep On Top", + "Keep the original stroke in front of new instances (only affect by layer)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); } static void rna_def_modifier_gpencilbuild(BlenderRNA *brna) |