Fix Skeleton3D regression when bones are not sorted from root to leaves

Tentative fix for missing bones when bones are not sorted as expected.
For example, if the root comes last, all child bones are removed and
the skeleton ends up with just the root.
This commit is contained in:
PouleyKetchoupp 2021-08-17 08:31:38 -07:00
parent 913a7a63d5
commit 91fdf7c15b

View file

@ -172,13 +172,16 @@ void Skeleton3D::_update_process_order() {
parentless_bones.clear();
for (int i = 0; i < len; i++) {
bonesptr[i].child_bones.clear();
}
for (int i = 0; i < len; i++) {
if (bonesptr[i].parent >= len) {
//validate this just in case
ERR_PRINT("Bone " + itos(i) + " has invalid parent: " + itos(bonesptr[i].parent));
bonesptr[i].parent = -1;
}
bonesptr[i].child_bones.clear();
if (bonesptr[i].parent != -1) {
int parent_bone_idx = bonesptr[i].parent;