summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-01-23 14:38:04 +0100
committerGitHub <noreply@github.com>2020-01-23 14:38:04 +0100
commitefea348fe8a37d99da48c2a2cfb3a44437d99af2 (patch)
treeef7f26b63acb395426a28e409ae3f5b81d78d9ea /scene
parente7e8318546cef3aa482d71c5b0ddd5a664e241eb (diff)
parent551c37167b0428b1489a8a6f6233624c5f4aa628 (diff)
Merge pull request #35460 from ericrybick/35409-skeleton-does-not-return-to-original-pose-when-ik-playback-is-stopped
Fix bone pose override not being reset when IK animation is stopped
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/skeleton_ik.cpp13
-rw-r--r--scene/animation/skeleton_ik.h1
2 files changed, 14 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() {
diff --git a/scene/animation/skeleton_ik.h b/scene/animation/skeleton_ik.h
index 9ae010dc4e..8fc8a58b99 100644
--- a/scene/animation/skeleton_ik.h
+++ b/scene/animation/skeleton_ik.h
@@ -139,6 +139,7 @@ public:
static void set_goal(Task *p_task, const Transform &p_goal);
static void make_goal(Task *p_task, const Transform &p_inverse_transf, real_t blending_delta);
static void solve(Task *p_task, real_t blending_delta, bool override_tip_basis, bool p_use_magnet, const Vector3 &p_magnet_position);
+ static void reset(Task *p_task);
};
class SkeletonIK : public Node {