From 4150749698bfc4f112dc63297318ece77bb982c4 Mon Sep 17 00:00:00 2001 From: hare_ware <32441086+CheesecakeCG@users.noreply.github.com> Date: Mon, 31 Oct 2022 06:59:42 -0400 Subject: [PATCH] Fix Skeleton3D falsely assuming all physical bones will be children of their first bone (cherry picked from commit 913f57f695e8b62612cb1e872b4ce1dc5d9ef057) --- scene/3d/skeleton.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 9bc9222b37f..50cf95784f9 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -707,10 +707,14 @@ void _pb_start_simulation(const Skeleton *p_skeleton, Node *p_node, const Vector PhysicalBone *pb = Object::cast_to(p_node); if (pb) { bool sim = false; - for (int i = p_sim_bones.size() - 1; 0 <= i; --i) { - if (p_sim_bones[i] == pb->get_bone_id() || p_skeleton->is_bone_parent_of(pb->get_bone_id(), p_sim_bones[i])) { - sim = true; - break; + if (p_sim_bones.empty()) { // If no bones is specified, activate ragdoll on full body. + sim = true; + } else { + for (int i = p_sim_bones.size() - 1; 0 <= i; --i) { + if (p_sim_bones[i] == pb->get_bone_id() || p_skeleton->is_bone_parent_of(pb->get_bone_id(), p_sim_bones[i])) { + sim = true; + break; + } } } @@ -725,9 +729,7 @@ void _pb_start_simulation(const Skeleton *p_skeleton, Node *p_node, const Vector void Skeleton::physical_bones_start_simulation_on(const Array &p_bones) { Vector sim_bones; - if (p_bones.size() <= 0) { - sim_bones.push_back(0); // if no bones is specified, activate ragdoll on full body - } else { + if (p_bones.size() > 0) { sim_bones.resize(p_bones.size()); int c = 0; for (int i = sim_bones.size() - 1; 0 <= i; --i) {