Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD. O <Likkez>2020-05-29 19:52:29 +0300
committerBastien Montagne <bastien@blender.org>2020-05-29 19:55:28 +0300
commit907cab45ff02ad1bba3cba98a3d6af69eff2bec0 (patch)
tree3c2275ebafdfdb882d4b127e1af593b044c7a707 /source/blender/modifiers/intern/MOD_weightvgmix.c
parentc93a88413d1499d43265af9580e993bf8963726d (diff)
Modifiers: add invert vgroup weights options to operands of Mix modifier.
Please note that vertices which are in a vgroup are not affected by this option (which means that affected vertices from 'selection' modes remain the same). Only the weights of selected vertices get inverted. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D7811
Diffstat (limited to 'source/blender/modifiers/intern/MOD_weightvgmix.c')
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 57156aec5ec..a71b1d9d0e8 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -225,6 +225,16 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
int i;
const bool invert_vgroup_mask = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_MASK) != 0;
const bool do_normalize = (wmd->flag & MOD_WVG_MIX_WEIGHTS_NORMALIZE) != 0;
+
+ /*
+ * Note that we only invert the weight values within provided vgroups, the selection based on
+ * which vertice is affected because it belongs or not to a group remains unchanged.
+ * In other words, vertices not belonging to a group won't be affected, even though their
+ * inverted 'virtual' weight would be 1.0f.
+ */
+ const bool invert_vgroup_a = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_A) != 0;
+ const bool invert_vgroup_b = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_B) != 0;
+
/* Flags. */
#if 0
const bool do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview) != 0;
@@ -379,8 +389,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* Mix weights. */
for (i = 0; i < numIdx; i++) {
float weight2;
- org_w[i] = dw1[i] ? dw1[i]->weight : wmd->default_weight_a;
- weight2 = dw2[i] ? dw2[i]->weight : wmd->default_weight_b;
+ if (invert_vgroup_a) {
+ org_w[i] = 1.0f - (dw1[i] ? dw1[i]->weight : wmd->default_weight_a);
+ }
+ else {
+ org_w[i] = dw1[i] ? dw1[i]->weight : wmd->default_weight_a;
+ }
+ if (invert_vgroup_b) {
+ weight2 = 1.0f - (dw2[i] ? dw2[i]->weight : wmd->default_weight_b);
+ }
+ else {
+ weight2 = dw2[i] ? dw2[i]->weight : wmd->default_weight_b;
+ }
new_w[i] = mix_weight(org_w[i], weight2, wmd->mix_mode);
}