[Bf-blender-cvs] [808fa22a7ad] master: Warp Modifier add invert vgroup option

Cody Winchester noreply at git.blender.org
Mon Feb 3 12:05:22 CET 2020


Commit: 808fa22a7ad8f954bda35dd07776154a24b884fe
Author: Cody Winchester
Date:   Mon Feb 3 12:01:13 2020 +0100
Branches: master
https://developer.blender.org/rB808fa22a7ad8f954bda35dd07776154a24b884fe

Warp Modifier add invert vgroup option

Adds the invert vertex weights option to the Warp Modifier. Setup in the same way as the other modifiers.

Uses the existing flag char that is labeled unused.

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

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index ae450f17e09..021a4600a73 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1139,7 +1139,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.label(text="To:")
         col.prop(md, "object_to", text="")
-        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 = layout.column()
 
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index a203e77ab26..39efe838bab 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1300,7 +1300,6 @@ typedef struct WarpModifierData {
   char defgrp_name[64];
   float strength;
   float falloff_radius;
-  /** Not used yet. */
   char flag;
   char falloff_type;
   char _pad[6];
@@ -1308,6 +1307,11 @@ typedef struct WarpModifierData {
 
 #define MOD_WARP_VOLUME_PRESERVE 1
 
+/* WarpModifierData->flag */
+enum {
+  MOD_WARP_INVERT_VGROUP = (1 << 0),
+};
+
 typedef enum {
   eWarp_Falloff_None = 0,
   eWarp_Falloff_Curve = 1,
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 394f74f3675..6f2f12ebf98 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1838,6 +1838,11 @@ static void rna_def_modifier_warp(BlenderRNA *brna)
   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WarpModifier_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_WARP_INVERT_VGROUP);
+  RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   rna_def_modifier_generic_map_info(srna);
 }
 
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 7155498c942..ba017577004 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -175,7 +175,7 @@ static void warpModifier_do(WarpModifierData *wmd,
   int i;
   int defgrp_index;
   MDeformVert *dvert, *dv = NULL;
-
+  const bool invert_vgroup = (wmd->flag & MOD_WARP_INVERT_VGROUP) != 0;
   float(*tex_co)[3] = NULL;
 
   if (!(wmd->object_from && wmd->object_to)) {
@@ -235,7 +235,8 @@ static void warpModifier_do(WarpModifierData *wmd,
       /* skip if no vert group found */
       if (defgrp_index != -1) {
         dv = &dvert[i];
-        weight = defvert_find_weight(dv, defgrp_index) * strength;
+        weight = invert_vgroup ? 1.0f - defvert_find_weight(dv, defgrp_index) * strength :
+                                 defvert_find_weight(dv, defgrp_index) * strength;
         if (weight <= 0.0f) {
           continue;
         }



More information about the Bf-blender-cvs mailing list