[Bf-blender-cvs] [fa715a158a4] master: Vertex Weight Mix: support Minimum and Maximum mix modes.

Alexander Gavrilov noreply at git.blender.org
Mon Feb 21 14:05:30 CET 2022


Commit: fa715a158a4c4576e944e79276864b1365a0ccc9
Author: Alexander Gavrilov
Date:   Sun Feb 20 01:52:43 2022 +0300
Branches: master
https://developer.blender.org/rBfa715a158a4c4576e944e79276864b1365a0ccc9

Vertex Weight Mix: support Minimum and Maximum mix modes.

The modifier supports arithmetic operations, like Add or Multiply,
but for some reason omits Minimum and Maximum. They are similarly
simple and useful math functions and should be supported.

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

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

M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_weightvgmix.c

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

diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index db5a3d69e4d..36f14e7d357 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1604,6 +1604,10 @@ enum {
   MOD_WVG_MIX_DIF = 6,
   /** Average of both weights. */
   MOD_WVG_MIX_AVG = 7,
+  /** Minimum of both weights. */
+  MOD_WVG_MIX_MIN = 8,
+  /** Maximum of both weights. */
+  MOD_WVG_MIX_MAX = 9,
 };
 
 /** #WeightVGMixModifierData.mix_set (what vertices to affect). */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 426f37dfb66..9f7e136ebf6 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5169,6 +5169,8 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
        "Difference",
        "Difference between VGroup A's and VGroup B's weights"},
       {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weights"},
+      {MOD_WVG_MIX_MIN, "MIN", 0, "Minimum", "Minimum of VGroup A's and VGroup B's weights"},
+      {MOD_WVG_MIX_MAX, "MAX", 0, "Maximum", "Maximum of VGroup A's and VGroup B's weights"},
       {0, NULL, 0, NULL, NULL},
   };
 
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 1078ebfaeb2..1b6472e2d42 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -105,6 +105,12 @@ static float mix_weight(float weight, float weight2, char mix_mode)
   if (mix_mode == MOD_WVG_MIX_AVG) {
     return (weight + weight2) * 0.5f;
   }
+  if (mix_mode == MOD_WVG_MIX_MIN) {
+    return (weight < weight2 ? weight : weight2);
+  }
+  if (mix_mode == MOD_WVG_MIX_MAX) {
+    return (weight > weight2 ? weight : weight2);
+  }
 
   return weight2;
 }



More information about the Bf-blender-cvs mailing list