Versioning: fix vertex group name loss in linked duplicates.
After rB3b6ee8cee708 by @HooglyBoogly vertex groups were moved to mesh data, and versioning code was provided to upgrade old files. However, it fails to consider the case of linked duplicates having different name lists, and dependent on the object order can cause some of the names to be lost. This can even be all of them, if there is a duplicate without any names, which can be easily created by lazy Python code. To fix this, change the code to use the longest available name list. Differential Revision: https://developer.blender.org/D11958
This commit is contained in:
parent
9eafdb985d
commit
fc32567cda
|
@ -99,9 +99,15 @@ static void move_vertex_group_names_to_object_data(Main *bmain)
|
|||
if (ELEM(object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) {
|
||||
ListBase *new_defbase = BKE_object_defgroup_list_mutable(object);
|
||||
|
||||
/* Clear the list in case the it was already assigned from another object. */
|
||||
BLI_freelistN(new_defbase);
|
||||
*new_defbase = object->defbase;
|
||||
/* Choose the longest vertex group name list among all linked duplicates. */
|
||||
if (BLI_listbase_count(&object->defbase) < BLI_listbase_count(new_defbase)) {
|
||||
BLI_freelistN(&object->defbase);
|
||||
}
|
||||
else {
|
||||
/* Clear the list in case the it was already assigned from another object. */
|
||||
BLI_freelistN(new_defbase);
|
||||
*new_defbase = object->defbase;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue