From 68b968ff6cdd050eb573fb513c93711f3001aea6 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 25 Apr 2020 10:57:42 -0400 Subject: [PATCH] Resets global pose of IK chain bones being solved, rather than the whole skeleton. Resolves #38026 (cherry picked from commit e321d38c0ec6261a861100260689aa022237112e) --- scene/animation/skeleton_ik.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp index 409fc0acc59..1dba88248ab 100644 --- a/scene/animation/skeleton_ik.cpp +++ b/scene/animation/skeleton_ik.cpp @@ -287,7 +287,15 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove return; // Skip solving } - p_task->skeleton->clear_bones_global_pose_override(); + p_task->skeleton->set_bone_global_pose_override(p_task->chain.chain_root.bone, Transform(), 0.0, true); + + if (p_task->chain.middle_chain_item) { + p_task->skeleton->set_bone_global_pose_override(p_task->chain.middle_chain_item->bone, Transform(), 0.0, true); + } + + for (int i = 0; i < p_task->chain.tips.size(); i += 1) { + p_task->skeleton->set_bone_global_pose_override(p_task->chain.tips[i].chain_item->bone, Transform(), 0.0, true); + } make_goal(p_task, p_task->skeleton->get_global_transform().affine_inverse().scaled(p_task->skeleton->get_global_transform().get_basis().get_scale()), blending_delta);