Fix #108473: unreliable auto-normalize results when weight painting in GPencil

Painting weights in Grease Pencil with the auto-normalize option enabled,
gave unpredictable results when vertex groups with a weight of zero
were involved.
This patch resolves the issue. Vertex weights of zero are excluded from
auto-normalization. Which is a better fit for the Grease Pencil workflow,
where weights are mostly painted from scratch since the 'parent to
armature with automatic weights' operator doesn't give good results.

Pull Request: https://projects.blender.org/blender/blender/pulls/108524
This commit is contained in:
Sietse Brouwer
2023-06-02 15:04:19 +02:00
committed by Falk David
parent 25952b865d
commit a784a65dbe

View File

@@ -418,7 +418,8 @@ static bool do_weight_paint_normalize_all_unlocked(MDeformVert *dvert,
dw = dvert->dw;
for (int i = dvert->totweight; i != 0; i--, dw++) {
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr]) {
/* Auto-normalize is only applied on bone-deformed vertex groups that have weight already. */
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr] && dw->weight > FLT_EPSILON) {
sum += dw->weight;
if (vgroup_locked[dw->def_nr] || (lock_active_vgroup && active_vgroup == dw->def_nr)) {
@@ -460,7 +461,8 @@ static bool do_weight_paint_normalize_all_unlocked(MDeformVert *dvert,
dw = dvert->dw;
for (int i = dvert->totweight; i != 0; i--, dw++) {
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr]) {
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr] && dw->weight > FLT_EPSILON)
{
if ((vgroup_locked[dw->def_nr] == false) &&
!(lock_active_vgroup && active_vgroup == dw->def_nr)) {
dw->weight *= fac;
@@ -475,7 +477,8 @@ static bool do_weight_paint_normalize_all_unlocked(MDeformVert *dvert,
dw = dvert->dw;
for (int i = dvert->totweight; i != 0; i--, dw++) {
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr]) {
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr] && dw->weight > FLT_EPSILON)
{
if ((vgroup_locked[dw->def_nr] == false) &&
!(lock_active_vgroup && active_vgroup == dw->def_nr)) {
dw->weight = fac;