Fix WPaint inactive when painting on a vgroup and the only other vgroup is locked.

`enforce_locks()` would reset weights of non-locked modified vgroups if it could not
find any other non-modified non-locked vgroup to 'distribute' weights into.
Sounds rather stupid, yet I hope I did not break something else, this code
is rather convoluted to say the least.

Side-reported by zeauro (ronan ducluzeau) in T43814, thanks!
This commit is contained in:
Bastien Montagne 2015-02-27 11:43:10 +01:00
parent a7e80a9470
commit d7a877b69c
1 changed files with 4 additions and 3 deletions

View File

@ -1575,8 +1575,8 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv,
change_status[i] = 1; /* can be altered while redistributing */
}
}
/* if there was any change, redistribute it */
if (total_changed) {
/* if there was any change, and somewhere to redistribute it, do it */
if (total_changed && total_valid) {
/* auto normalize will allow weights to temporarily go above 1 in redistribution */
if (vgroup_validmap && total_changed < 0 && total_valid) {
totchange_allowed = total_valid;
@ -1740,7 +1740,8 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi,
}
clamp_weights(dv);
enforce_locks(&dv_test, dv, wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags, wpi->vgroup_validmap, wpi->do_auto_normalize, wpi->do_multipaint);
enforce_locks(&dv_test, dv, wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags, wpi->vgroup_validmap,
wpi->do_auto_normalize, wpi->do_multipaint);
if (wpi->do_auto_normalize) {
/* XXX - should we pass the active group? - currently '-1' */