Fix: USD import: deform group name collision #111747

Open
Michael Kowalski wants to merge 7 commits from makowalski/blender:usd_deform_group_name_collision into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 7 additions and 0 deletions
Showing only changes of commit 2bbbbe4fc8 - Show all commits

View File

@ -1018,6 +1018,13 @@ void import_mesh_skel_bindings(Main *bmain, Object *mesh_obj, const pxr::UsdPrim
/* If there is an attribute with the same name, remove it. */
bke::AttributeIDRef attr_id(joint_name);
makowalski marked this conversation as resolved Outdated

You can use if (attributes.remove(joint_name)), since it returns whether an attribute was deleted or not.

You can use `if (attributes.remove(joint_name))`, since it returns whether an attribute was deleted or not.
if (attributes.contains(attr_id)) {
makowalski marked this conversation as resolved Outdated

You can rely on the implicit conversion to bke::AttributeIDRef, no need to create it on a separate line.

You can rely on the implicit conversion to `bke::AttributeIDRef`, no need to create it on a separate line.
WM_reportf(
RPT_WARNING,
"%s: Removing attribute '%s' from mesh '%s', as it conflicts with a deform group "
makowalski marked this conversation as resolved Outdated

I think the message could be a bit more concise. Also not sure about adding the function name in there, that seems a bit "low level" for a warning message in the UI. How about something like this?

Attribute '%s' removed from mesh '%s` because of name conflict with vertex group

(vertex group is what "defgroup" is called in the UI, I guess the code was just never updated for a rename or something)

I think the message could be a bit more concise. Also not sure about adding the function name in there, that seems a bit "low level" for a warning message in the UI. How about something like this? ``` Attribute '%s' removed from mesh '%s` because of name conflict with vertex group ``` (vertex group is what "defgroup" is called in the UI, I guess the code was just never updated for a rename or something)
"for a bone with the same name",
__func__,
joint_name.c_str(),
mesh->id.name + 2);
attributes.remove(attr_id);
}
bDeformGroup *def_grp = BKE_object_defgroup_add_name(mesh_obj, joint_name.c_str());