[Bf-blender-cvs] [7bbbb9ba8a1] master: Displace Modifier add invert vgroup option

Cody Winchester noreply at git.blender.org
Mon Feb 3 12:00:24 CET 2020


Commit: 7bbbb9ba8a139b96fe9484e05d3db43fb5ad0a18
Author: Cody Winchester
Date:   Mon Feb 3 11:55:29 2020 +0100
Branches: master
https://developer.blender.org/rB7bbbb9ba8a139b96fe9484e05d3db43fb5ad0a18

Displace Modifier add invert vgroup option

Adds the invert vertex weights option to the Displace modifier.

Adds a flag and char padding to the Displace modifier DNA for the invert group boolean.

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

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 197566f16f3..ae450f17e09 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -381,7 +381,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
             col.label(text="Space:")
             col.prop(md, "space", text="")
         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')
 
         col = split.column(align=True)
         col.active = has_texture
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 62817c3b563..a203e77ab26 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -492,8 +492,15 @@ typedef struct DisplaceModifierData {
   char defgrp_name[64];
   float midlevel;
   int space;
+  short flag;
+  char _pad[6];
 } DisplaceModifierData;
 
+/* DisplaceModifierData->flag */
+enum {
+  MOD_DISP_INVERT_VGROUP = (1 << 0),
+};
+
 /* DisplaceModifierData->direction */
 enum {
   MOD_DISP_DIR_X = 0,
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 8117085974c..394f74f3675 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2889,6 +2889,11 @@ static void rna_def_modifier_displace(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Space", "");
   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
+  prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DISP_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_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 9cb694be88b..7f65b3bb5ae 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -174,6 +174,7 @@ static void displaceModifier_do_task(void *__restrict userdata,
   DisplaceUserdata *data = (DisplaceUserdata *)userdata;
   DisplaceModifierData *dmd = data->dmd;
   MDeformVert *dvert = data->dvert;
+  const bool invert_vgroup = (dmd->flag & MOD_DISP_INVERT_VGROUP) != 0;
   float weight = data->weight;
   int defgrp_index = data->defgrp_index;
   int direction = data->direction;
@@ -192,7 +193,8 @@ static void displaceModifier_do_task(void *__restrict userdata,
   float local_vec[3];
 
   if (dvert) {
-    weight = defvert_find_weight(dvert + iter, defgrp_index);
+    weight = invert_vgroup ? 1.0f - defvert_find_weight(dvert + iter, defgrp_index) :
+                             defvert_find_weight(dvert + iter, defgrp_index);
     if (weight == 0.0f) {
       return;
     }



More information about the Bf-blender-cvs mailing list