Anim: Fix incorrect fix for weight paint Smooth Operator

#138435 was an attempt to fix the issue in #138168 where the Smooth
Operator modifies locked vertex groups. Unfortunately, the fix actually
changed some already-correct code to be incorrect to compensate for the
buggy code in the Smooth Operator.

This reverts that fix and applies a correct fix, which is to exclude
locked vertex groups in the Smooth Operator's code itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/141093
This commit is contained in:
Nathan Vegdahl
2025-06-30 11:53:09 +02:00
committed by Nathan Vegdahl
parent b4eeddd113
commit 2630fc4978
2 changed files with 13 additions and 4 deletions

View File

@@ -794,15 +794,12 @@ bool *BKE_object_defgroup_subset_from_select_type(Object *ob,
case WT_VGROUP_BONE_DEFORM: {
int i;
defgroup_validmap = BKE_object_defgroup_validmap_get(ob, *r_defgroup_tot);
const bool *locked_vgroups = BKE_object_defgroup_lock_flags_get(ob, *r_defgroup_tot);
*r_subset_count = 0;
for (i = 0; i < *r_defgroup_tot; i++) {
defgroup_validmap[i] &= !(locked_vgroups && locked_vgroups[i]);
if (defgroup_validmap[i] == true) {
*r_subset_count += 1;
}
}
MEM_SAFE_FREE(locked_vgroups);
break;
}
case WT_VGROUP_BONE_DEFORM_OFF: {

View File

@@ -3419,10 +3419,22 @@ static wmOperatorStatus vertex_group_smooth_exec(bContext *C, wmOperator *op)
for (Object *ob : objects) {
int subset_count, vgroup_tot;
const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(
bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(
ob, subset_type, &vgroup_tot, &subset_count);
if (vgroup_tot) {
const bool *locked_vgroups = BKE_object_defgroup_lock_flags_get(ob, vgroup_tot);
if (locked_vgroups) {
/* Remove locked groups from the vgroup valid map. */
for (int i = 0; i < vgroup_tot; i++) {
if (vgroup_validmap[i] && locked_vgroups[i]) {
vgroup_validmap[i] = false;
subset_count--;
}
}
}
MEM_SAFE_FREE(locked_vgroups);
has_vgroup_multi = true;
if (subset_count) {