Anim: fix bug in name uniqueness check for editbones

Fix the name uniqueness check for editbones. The function can receive a
"bone to ignore", which would not be properly ignored. If it was found
earlier in `armature->edbo` than another bone with the same name, the
name would incorrectly be marked as unique.

This issue only occurred when a "bone to ignore" was passed to the
uniqueness check. This never actually happens in the current code, but
that's going to change soon.
This commit is contained in:
Sybren A. Stüvel 2024-03-22 09:52:58 +01:00
parent 62f140e048
commit ce8a032ac2
1 changed files with 14 additions and 1 deletions

View File

@ -22,6 +22,7 @@
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_listbase_wrapper.hh"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
@ -53,7 +54,7 @@
#include "armature_intern.hh"
using blender::Vector;
using namespace blender;
/* -------------------------------------------------------------------- */
/** \name Unique Bone Name Utility (Edit Mode)
@ -66,6 +67,18 @@ static bool editbone_unique_check(void *arg, const char *name)
ListBase *lb;
void *bone;
} *data = static_cast<Arg *>(arg);
if (data->bone) {
/* This indicates that there is a bone to ignore. This means ED_armature_ebone_find_name()
* cannot be used, as it might return the bone we should be ignoring. */
for (EditBone *ebone : ListBaseWrapper<EditBone>(data->lb)) {
if (STREQ(ebone->name, name) && ebone != data->bone) {
return true;
}
}
return false;
}
EditBone *dupli = ED_armature_ebone_find_name(data->lb, name);
return dupli && dupli != data->bone;
}