[Bf-blender-cvs] [059f3c1a7eb] master: Modifiers: Wave add invert vgroup option

Bastien Montagne noreply at git.blender.org
Tue Mar 3 18:42:27 CET 2020


Commit: 059f3c1a7eb8a48aa06467e19cce4daa29091c1a
Author: Bastien Montagne
Date:   Tue Mar 3 18:41:50 2020 +0100
Branches: master
https://developer.blender.org/rB059f3c1a7eb8a48aa06467e19cce4daa29091c1a

Modifiers: Wave add invert vgroup option

Adds the invert vgroup option to the Wave modifier.

Differential Revision: https://developer.blender.org/D6893

===================================================================

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_wave.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 158202b0ba3..603c873c290 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1217,7 +1217,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.separator()
 
         layout.prop(md, "start_position_object")
-        layout.prop_search(md, "vertex_group", ob, "vertex_groups")
+        row = layout.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(factor=0.33)
         col = split.column()
         col.label(text="Texture")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 572a9fd76ba..36d21b28b1f 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -673,7 +673,7 @@ typedef struct WaveModifierData {
 
 /* WaveModifierData.flag */
 enum {
-  /* And what bout (1 << 0) flag? ;) */
+  MOD_WAVE_INVERT_VGROUP = (1 << 0),
   MOD_WAVE_X = (1 << 1),
   MOD_WAVE_Y = (1 << 2),
   MOD_WAVE_CYCL = (1 << 3),
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index cc0ebd8e6b2..025cae42033 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2356,6 +2356,11 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WaveModifier_defgrp_name_set");
   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_WAVE_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, "speed", PROP_FLOAT, PROP_NONE);
   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
   RNA_def_property_ui_range(prop, -1, 1, 10, 2);
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index ff5748b968c..d4d8d253254 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -154,6 +154,7 @@ static void waveModifier_do(WaveModifierData *md,
   const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y);
   const float falloff = wmd->falloff;
   float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */
+  const bool invert_group = (wmd->flag & MOD_WAVE_INVERT_VGROUP) != 0;
 
   if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) {
     mvert = mesh->mvert;
@@ -213,7 +214,8 @@ static void waveModifier_do(WaveModifierData *md,
 
       /* get weights */
       if (dvert) {
-        def_weight = defvert_find_weight(&dvert[i], defgrp_index);
+        def_weight = invert_group ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) :
+                                     defvert_find_weight(&dvert[i], defgrp_index);
 
         /* if this vert isn't in the vgroup, don't deform it */
         if (def_weight == 0.0f) {



More information about the Bf-blender-cvs mailing list