diff options
author | Cody Winchester <CodyWinch> | 2020-09-19 07:08:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-09-20 05:54:38 +0300 |
commit | e0f13f41c68172ca61f76b85fdf281fabb48c8b5 (patch) | |
tree | d26ee20251002058893d1593f5c3fbfdad24b149 | |
parent | 94a63f75055024dbf0c9f9236b3cda5438fa2162 (diff) |
Fix invert vertex group weight miscalculation for modifiers
Warp & weight vertex-group editing modifiers miscalculated vertex weight
inversion, the weights were multiplied before being subtracted from 1.
Ref D8241
-rw-r--r-- | source/blender/modifiers/intern/MOD_warp.c | 5 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvg_util.c | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index bb0896994b1..2e4e4da6803 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -279,8 +279,9 @@ static void warpModifier_do(WarpModifierData *wmd, /* skip if no vert group found */ if (defgrp_index != -1) { dv = &dvert[i]; - weight = invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, defgrp_index) * strength : - BKE_defvert_find_weight(dv, defgrp_index) * strength; + weight = (invert_vgroup ? (1.0f - BKE_defvert_find_weight(dv, defgrp_index)) : + BKE_defvert_find_weight(dv, defgrp_index)) * + strength; if (weight <= 0.0f) { continue; } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 4ee1f9f669a..1c1ca08183d 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -249,9 +249,10 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, /* For each weight (vertex), make the mix between org and new weights. */ for (i = 0; i < num; i++) { int idx = indices ? indices[i] : i; - const float f = invert_vgroup_mask ? - 1.0f - BKE_defvert_find_weight(&dvert[idx], ref_didx) * fact : - BKE_defvert_find_weight(&dvert[idx], ref_didx) * fact; + const float f = (invert_vgroup_mask ? + (1.0f - BKE_defvert_find_weight(&dvert[idx], ref_didx)) : + BKE_defvert_find_weight(&dvert[idx], ref_didx)) * + fact; org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f)); /* If that vertex is not in ref vgroup, assume null factor, and hence do nothing! */ } |