summaryrefslogtreecommitdiff
path: root/scene/animation/skeleton_ik.cpp
diff options
context:
space:
mode:
authorEric Rybicki <info@ericrybicki.com>2020-01-23 08:48:08 +0100
committerEric Rybicki <info@ericrybicki.com>2020-01-23 08:48:08 +0100
commit551c37167b0428b1489a8a6f6233624c5f4aa628 (patch)
treef5b88d29af1381f1b7a09a18f8bfcf0e24ea2c32 /scene/animation/skeleton_ik.cpp
parent91b0be18dcc3ba3b1ecd35e8a7e416883776cf7b (diff)
Fix bone pose override not being reset when IK animation is stopped
Fixes #35409
Diffstat (limited to 'scene/animation/skeleton_ik.cpp')
-rw-r--r--scene/animation/skeleton_ik.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp
index 518c243dd0..46028a9ce2 100644
--- a/scene/animation/skeleton_ik.cpp
+++ b/scene/animation/skeleton_ik.cpp
@@ -329,6 +329,17 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
}
}
+void FabrikInverseKinematic::reset(Task *p_task) {
+ ChainItem *ci(&p_task->chain.chain_root);
+ while (ci) {
+ p_task->skeleton->set_bone_global_pose_override(ci->bone, Transform(), 0);
+ if (!ci->children.empty())
+ ci = &ci->children.write[0];
+ else
+ ci = NULL;
+ }
+}
+
void SkeletonIK::_validate_property(PropertyInfo &property) const {
if (property.name == "root_bone" || property.name == "tip_bone") {
@@ -531,6 +542,8 @@ void SkeletonIK::start(bool p_one_time) {
void SkeletonIK::stop() {
set_process_internal(false);
+ if (task)
+ FabrikInverseKinematic::reset(task);
}
Transform SkeletonIK::_get_target_transform() {