diff options
author | Cody Winchester <CodyWinch> | 2020-01-27 16:03:24 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2020-01-27 16:46:01 +0300 |
commit | 1094e560413d38e9834ae563ef248f898cb8b201 (patch) | |
tree | 4ca12baecce5ef734cb6f5dee69b29ff65104938 | |
parent | 2ab5ca81a5379cb99dfc134efffe070d4851d311 (diff) |
Cast modifier: Add invert vgroup option.
Adds the Invert Vertex Group weight option to the Cast modifier.
Uses the same setup as similar modifiers invert weight.
Adds a boolean invert property next to the vertex group string in the modifier
and subtracts the current vertex weight from 1.0f if it is turned on.
Differential Revision: https://developer.blender.org/D6671
Minor modifications by @mont29.
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_modifier.py | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 5 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_cast.c | 11 |
4 files changed, 18 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index d4b2c39bd5e..197566f16f3 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -293,7 +293,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.label(text="Vertex Group:") - col.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + row = col.row(align=True) + row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT') col = split.column() col.label(text="Control Object:") col.prop(md, "object", text="") diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 9db993cca59..62817c3b563 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -611,6 +611,7 @@ typedef struct CastModifierData { /* Cast modifier flags */ enum { /* And what bout (1 << 0) flag? ;) */ + MOD_CAST_INVERT_VGROUP = (1 << 0), MOD_CAST_X = (1 << 1), MOD_CAST_Y = (1 << 2), MOD_CAST_Z = (1 << 3), diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 589ce1414bb..8117085974c 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -3217,6 +3217,11 @@ static void rna_def_modifier_cast(BlenderRNA *brna) RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_X); RNA_def_property_ui_text(prop, "X", ""); diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 0bf1dd8e2b3..b070a3c7127 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -105,6 +105,7 @@ static void sphere_do(CastModifierData *cmd, int numVerts) { MDeformVert *dvert = NULL; + const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0; Object *ctrl_ob = NULL; @@ -198,7 +199,9 @@ static void sphere_do(CastModifierData *cmd, } if (dvert) { - const float weight = defvert_find_weight(&dvert[i], defgrp_index); + const float weight = invert_vgroup ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) : + defvert_find_weight(&dvert[i], defgrp_index); + if (weight == 0.0f) { continue; } @@ -240,6 +243,8 @@ static void cuboid_do(CastModifierData *cmd, int numVerts) { MDeformVert *dvert = NULL; + const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0; + Object *ctrl_ob = NULL; int i, defgrp_index; @@ -365,7 +370,9 @@ static void cuboid_do(CastModifierData *cmd, } if (dvert) { - const float weight = defvert_find_weight(&dvert[i], defgrp_index); + const float weight = invert_vgroup ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) : + defvert_find_weight(&dvert[i], defgrp_index); + if (weight == 0.0f) { continue; } |