[Bf-blender-cvs] [26ef4fa85ef] master: Modifiers: Vertex Weight Edit add invert curve falloff option

Cody Winchester noreply at git.blender.org
Tue Mar 24 18:29:07 CET 2020


Commit: 26ef4fa85ef4ea0f010f31c93d1086c515c3b5d4
Author: Cody Winchester
Date:   Tue Mar 24 17:48:46 2020 +0100
Branches: master
https://developer.blender.org/rB26ef4fa85ef4ea0f010f31c93d1086c515c3b5d4

Modifiers: Vertex Weight Edit add invert curve falloff option

This commit adds the option to invert the resulting weights of the
falloff curve.

There is a workflow used by some to convert a texture mask into
vertex weights by using a custom curve and inverting the points.
This allows the same effect with a single click, and gives the modifier
more procedural functionality.

With minor UI tweaks by @mont29.

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

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 277791a9f53..670f937e52a 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1350,7 +1350,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         layout.separator()
 
-        layout.prop(md, "falloff_type")
+        row = layout.row(align=True)
+        row.prop(md, "falloff_type")
+        row.prop(md, "invert_falloff", text="", icon='ARROW_LEFTRIGHT')
         if md.falloff_type == 'CURVE':
             layout.template_curve_mapping(md, "map_curve")
 
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 13c5a0913c6..b0b003d4b29 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1397,7 +1397,8 @@ typedef struct WeightVGEditModifierData {
 
 /* WeightVGEdit flags. */
 enum {
-  /* (1 << 0) and (1 << 1) are free for future use! */
+  /* (1 << 0) is free for future use! */
+  MOD_WVG_INVERT_FALLOFF = (1 << 1),
   MOD_WVG_EDIT_INVERT_VGROUP_MASK = (1 << 2),
   /** Add vertices with higher weight than threshold to vgroup. */
   MOD_WVG_EDIT_ADD2VG = (1 << 3),
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index a91dd2e33c7..a42c3e6a171 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4862,6 +4862,11 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_EDIT_INVERT_VGROUP_MASK);
   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group mask influence");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "invert_falloff", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_INVERT_FALLOFF);
+  RNA_def_property_ui_text(prop, "Invert Falloff", "Invert the resulting falloff weight");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 6acbbefe745..2b2a4cf85ea 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -244,6 +244,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
     }
   }
 
+  /* Invert resulting weights */
+  if ((wmd->edit_flags & MOD_WVG_INVERT_FALLOFF) != 0) {
+    for (i = 0; i < numVerts; i++) {
+      new_w[i] = 1.0f - new_w[i];
+    }
+  }
+
+
   /* Do masking. */
   struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
   weightvg_do_mask(ctx,



More information about the Bf-blender-cvs mailing list