[Bf-blender-cvs] [dd00e8ecd64] master: Smooth Modifier add invert vgroup option

Cody Winchester noreply at git.blender.org
Thu Feb 6 11:54:56 CET 2020


Commit: dd00e8ecd642cafc6294ec7f0f31c5e0e0fe9870
Author: Cody Winchester
Date:   Thu Feb 6 11:52:24 2020 +0100
Branches: master
https://developer.blender.org/rBdd00e8ecd642cafc6294ec7f0f31c5e0e0fe9870

Smooth Modifier add invert vgroup option

Adds the invert vertex group option to the smooth modifier.

Setup same way as previous modifiers.

Reviewed By: mont29

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

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index a8b9de409c2..b91c7f71843 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -969,7 +969,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "factor")
         col.prop(md, "iterations")
         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')
 
     def SOFT_BODY(self, layout, _ob, _md):
         layout.label(text="Settings are inside the Physics tab")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 135ddd8f62f..fcf41481ade 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -610,6 +610,7 @@ typedef struct SmoothModifierData {
 
 /* Smooth modifier flags */
 enum {
+  MOD_SMOOTH_INVERT_VGROUP = (1 << 0),
   MOD_SMOOTH_X = (1 << 1),
   MOD_SMOOTH_Y = (1 << 2),
   MOD_SMOOTH_Z = (1 << 3),
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 5b7db50ca02..0d953728c5e 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3040,6 +3040,11 @@ static void rna_def_modifier_smooth(BlenderRNA *brna)
       "Name of Vertex Group which determines influence of modifier per point");
   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SmoothModifier_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_SMOOTH_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_correctivesmooth(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index c8bc3aaa484..59ed3b0b005 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -101,6 +101,7 @@ static void smoothModifier_do(
 
   const float fac_new = smd->fac;
   const float fac_orig = 1.0f - fac_new;
+  const bool invert_vgroup = (smd->flag & MOD_SMOOTH_INVERT_VGROUP) != 0;
 
   MEdge *medges = mesh->medge;
   const int num_edges = mesh->totedge;
@@ -139,7 +140,8 @@ static void smoothModifier_do(
         }
         float *vco_new = accumulated_vecs[i];
 
-        const float f_new = defvert_find_weight(dv, defgrp_index) * fac_new;
+        const float f_new = invert_vgroup ? (1.0f - defvert_find_weight(dv, defgrp_index)) * fac_new :
+                                             defvert_find_weight(dv, defgrp_index) * fac_new;
         if (f_new <= 0.0f) {
           continue;
         }



More information about the Bf-blender-cvs mailing list