FIX #110946: vgroup normalize all check if armature is deforming before normalizing
If an armature is present, but not active the group_select_mode defaults to WT_VGROUP_BONE_DEFORM, and throws an error because it can't find any active vertex groups. we're now checking to see if any bone is actively deforming before switching to WT_VGROUP_BONE_DEFORM (else defaulting to WT_VGROUP_ALL) Pull Request: https://projects.blender.org/blender/blender/pulls/112648
This commit is contained in:
parent
2d1cbac809
commit
d1f250c0bc
@ -2888,14 +2888,40 @@ void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot)
|
||||
/** \name Vertex Group Normalize All Operator
|
||||
* \{ */
|
||||
|
||||
/*
|
||||
* For a given object, determine which target vertex group to normalize.
|
||||
*/
|
||||
static eVGroupSelect normalize_vertex_group_target(Object *ob)
|
||||
{
|
||||
/* Default to All Groups. */
|
||||
eVGroupSelect target_group = WT_VGROUP_ALL;
|
||||
|
||||
/* If armature is present, and armature is actively deforming the object
|
||||
(i.e armature modifier isn't disabled) use BONE DEFORM. */
|
||||
if (BKE_modifiers_is_deformed_by_armature(ob)) {
|
||||
|
||||
int defgroup_tot = BKE_object_defgroup_count(ob);
|
||||
bool *defgroup_validmap = BKE_object_defgroup_validmap_get(ob, defgroup_tot);
|
||||
|
||||
for (int i = 0; i < defgroup_tot; i++) {
|
||||
if (defgroup_validmap[i] == true) {
|
||||
target_group = WT_VGROUP_BONE_DEFORM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
MEM_freeN(defgroup_validmap);
|
||||
}
|
||||
|
||||
return target_group;
|
||||
}
|
||||
|
||||
static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
|
||||
/* If armature is present, default to `Deform Bones` otherwise `All Groups`. */
|
||||
RNA_enum_set(op->ptr,
|
||||
"group_select_mode",
|
||||
BKE_modifiers_is_deformed_by_armature(ob) ? WT_VGROUP_BONE_DEFORM : WT_VGROUP_ALL);
|
||||
eVGroupSelect target_group = normalize_vertex_group_target(ob);
|
||||
|
||||
RNA_enum_set(op->ptr, "group_select_mode", target_group);
|
||||
|
||||
bool lock_active = RNA_boolean_get(op->ptr, "lock_active");
|
||||
eVGroupSelect subset_type = static_cast<eVGroupSelect>(
|
||||
|
Loading…
Reference in New Issue
Block a user