[Bf-blender-cvs] [1094e560413] master: Cast modifier: Add invert vgroup option.

Cody Winchester noreply at git.blender.org
Mon Jan 27 14:46:28 CET 2020


Commit: 1094e560413d38e9834ae563ef248f898cb8b201
Author: Cody Winchester
Date:   Mon Jan 27 14:03:24 2020 +0100
Branches: master
https://developer.blender.org/rB1094e560413d38e9834ae563ef248f898cb8b201

Cast modifier: Add invert vgroup option.

Adds the Invert Vertex Group weight option to the Cast modifier.
Uses the same setup as similar modifiers invert weight.
Adds a boolean invert property next to the vertex group string in the modifier
and subtracts the current vertex weight from 1.0f if it is turned on.

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

Minor modifications by @mont29.

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index d4b2c39bd5e..197566f16f3 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -293,7 +293,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         col = split.column()
         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()
         col.label(text="Control Object:")
         col.prop(md, "object", text="")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 9db993cca59..62817c3b563 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -611,6 +611,7 @@ typedef struct CastModifierData {
 /* Cast modifier flags */
 enum {
   /* And what bout (1 << 0) flag? ;) */
+  MOD_CAST_INVERT_VGROUP = (1 << 0),
   MOD_CAST_X = (1 << 1),
   MOD_CAST_Y = (1 << 2),
   MOD_CAST_Z = (1 << 3),
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 589ce1414bb..8117085974c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3217,6 +3217,11 @@ static void rna_def_modifier_cast(BlenderRNA *brna)
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
   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_CAST_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, "use_x", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_X);
   RNA_def_property_ui_text(prop, "X", "");
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 0bf1dd8e2b3..b070a3c7127 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -105,6 +105,7 @@ static void sphere_do(CastModifierData *cmd,
                       int numVerts)
 {
   MDeformVert *dvert = NULL;
+  const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0;
 
   Object *ctrl_ob = NULL;
 
@@ -198,7 +199,9 @@ static void sphere_do(CastModifierData *cmd,
     }
 
     if (dvert) {
-      const float weight = defvert_find_weight(&dvert[i], defgrp_index);
+      const float weight = invert_vgroup ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) :
+                                           defvert_find_weight(&dvert[i], defgrp_index);
+
       if (weight == 0.0f) {
         continue;
       }
@@ -240,6 +243,8 @@ static void cuboid_do(CastModifierData *cmd,
                       int numVerts)
 {
   MDeformVert *dvert = NULL;
+  const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0;
+
   Object *ctrl_ob = NULL;
 
   int i, defgrp_index;
@@ -365,7 +370,9 @@ static void cuboid_do(CastModifierData *cmd,
     }
 
     if (dvert) {
-      const float weight = defvert_find_weight(&dvert[i], defgrp_index);
+      const float weight = invert_vgroup ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) :
+                                           defvert_find_weight(&dvert[i], defgrp_index);
+
       if (weight == 0.0f) {
         continue;
       }



More information about the Bf-blender-cvs mailing list