[Bf-blender-cvs] [d0cc9b522df] master: Modifiers: Laplacian Smooth modifier add invert vgroup option

Cody Winchester noreply at git.blender.org
Tue Feb 18 16:39:37 CET 2020


Commit: d0cc9b522dfb56e329f894d2c188bdcdfd175609
Author: Cody Winchester
Date:   Tue Feb 18 16:28:02 2020 +0100
Branches: master
https://developer.blender.org/rBd0cc9b522dfb56e329f894d2c188bdcdfd175609

Modifiers: Laplacian Smooth modifier add invert vgroup option

Adds the invert vgroup option to the Laplacian Smooth modifier.

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

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 6159504b68a..f0a6cccb62e 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -525,7 +525,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "use_normalized")
 
         layout.label(text="Vertex Group:")
-        layout.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        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')
 
     def LATTICE(self, layout, ob, md):
         split = layout.split()
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 2c19d4655d7..98ffe7ef416 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1683,6 +1683,7 @@ enum {
   MOD_LAPLACIANSMOOTH_Z = (1 << 3),
   MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME = (1 << 4),
   MOD_LAPLACIANSMOOTH_NORMALIZED = (1 << 5),
+  MOD_LAPLACIANSMOOTH_INVERT_VGROUP = (1 << 6),
 };
 
 typedef struct CorrectiveSmoothDeltaCache {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 654cb5f99fc..9d5c07ef0f0 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3212,6 +3212,11 @@ static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna)
       "Name of Vertex Group which determines influence of modifier per point");
   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LaplacianSmoothModifier_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_LAPLACIANSMOOTH_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_cast(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index dbe776ed32a..ea788d3f72b 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -378,6 +378,7 @@ static void laplaciansmoothModifier_do(
   float w, wpaint;
   int i, iter;
   int defgrp_index;
+  const bool invert_vgroup = (smd->flag & MOD_LAPLACIANSMOOTH_INVERT_VGROUP) != 0;
 
   sys = init_laplacian_system(mesh->totedge, mesh->totpoly, mesh->totloop, numVerts);
   if (!sys) {
@@ -420,7 +421,8 @@ static void laplaciansmoothModifier_do(
       EIG_linear_solver_right_hand_side_add(sys->context, 2, i, vertexCos[i][2]);
       if (iter == 0) {
         if (dv) {
-          wpaint = defvert_find_weight(dv, defgrp_index);
+          wpaint = invert_vgroup ? 1.0f - defvert_find_weight(dv, defgrp_index) :
+                                   defvert_find_weight(dv, defgrp_index);
           dv++;
         }
         else {



More information about the Bf-blender-cvs mailing list