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
This commit is contained in:
parent
5c11ca10c0
commit
fa715a158a
|
@ -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). */
|
||||
|
|
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue