From 91fdf7c15b9e60a89916e50d43e66ecc8afca204 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Tue, 17 Aug 2021 08:31:38 -0700 Subject: 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. --- scene/3d/skeleton_3d.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scene') 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 @@ -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; -- cgit v1.2.3