summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-08-17 08:31:38 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-08-17 08:31:38 -0700
commit91fdf7c15b9e60a89916e50d43e66ecc8afca204 (patch)
tree6f9dd25a3cff83befe4bffce2ef3df90b1f92cc7
parent913a7a63d5260e32ac992ff419f35992446ead0b (diff)
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.
-rw-r--r--scene/3d/skeleton_3d.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index 857916e23d..94fb49ae81 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -173,12 +173,15 @@ 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;