[Bf-blender-cvs] [42e8660] master: Simple Deform modifier: invert vgroup option
Campbell Barton
noreply at git.blender.org
Mon Mar 7 01:37:33 CET 2016
Commit: 42e86602721170c8fbb9d68a1a201a1d78052d72
Author: Campbell Barton
Date: Mon Mar 7 11:28:21 2016 +1100
Branches: master
https://developer.blender.org/rB42e86602721170c8fbb9d68a1a201a1d78052d72
Simple Deform modifier: invert vgroup option
D1839 from @Orgold
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/intern/MOD_simpledeform.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 30ca175..cf93971 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -788,7 +788,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')
split = layout.split()
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index c215951..457db70 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -848,10 +848,17 @@ typedef struct SimpleDeformModifierData {
char mode; /* deform function */
char axis; /* lock axis (for taper and strech) */
- char pad[2];
+ char flag;
+ char pad;
} SimpleDeformModifierData;
+/* SimpleDeform->flag */
+enum {
+ MOD_SIMPLEDEFORM_FLAG_INVERT_VGROUP = (1 << 0),
+};
+
+
enum {
MOD_SIMPLEDEFORM_MODE_TWIST = 1,
MOD_SIMPLEDEFORM_MODE_BEND = 2,
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 571d7fb..0c4b3ba 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3174,6 +3174,11 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_Y);
RNA_def_property_ui_text(prop, "Lock Y Axis", "Do not allow deformation along the Y axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SIMPLEDEFORM_FLAG_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_surface(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index f4fbfa7..588b56d 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -214,10 +214,15 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
}
modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup);
+ const bool invert_vgroup = (smd->flag & MOD_SIMPLEDEFORM_FLAG_INVERT_VGROUP) != 0;
for (i = 0; i < numVerts; i++) {
float weight = defvert_array_find_weight_safe(dvert, i, vgroup);
+ if (invert_vgroup) {
+ weight = 1.0f - weight;
+ }
+
if (weight != 0.0f) {
float co[3], dcut[3] = {0.0f, 0.0f, 0.0f};
More information about the Bf-blender-cvs
mailing list