Skip to content

Commit

Permalink
Fix bone pose override not being reset when IK animation is stopped
Browse files Browse the repository at this point in the history
Fixes #35409
  • Loading branch information
ericrybick committed Jan 23, 2020
1 parent 91b0be1 commit 551c371
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scene/animation/skeleton_ik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions scene/animation/skeleton_ik.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class FabrikInverseKinematic {
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 {
Expand Down

0 comments on commit 551c371

Please sign in to comment.