diff options
Diffstat (limited to 'scene/animation/animation_tree.cpp')
-rw-r--r-- | scene/animation/animation_tree.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 572e767f44..b0590bc2bd 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -541,9 +541,9 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { player->get_animation_list(&sname); Ref<Animation> reset_anim; - bool has_reset_anim = player->has_animation("RESET"); + bool has_reset_anim = player->has_animation(SceneStringNames::get_singleton()->RESET); if (has_reset_anim) { - reset_anim = player->get_animation("RESET"); + reset_anim = player->get_animation(SceneStringNames::get_singleton()->RESET); } for (const StringName &E : sname) { Ref<Animation> anim = player->get_animation(E); @@ -570,7 +570,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } if (!track) { - RES resource; + Ref<Resource> resource; Vector<StringName> leftover_path; Node *child = parent->get_node_and_resource(path, resource, leftover_path); @@ -633,8 +633,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { track_xform->bone_idx = bone_idx; Transform3D rest = sk->get_bone_rest(bone_idx); track_xform->init_loc = rest.origin; - track_xform->ref_rot = rest.basis.get_rotation_quaternion(); - track_xform->init_rot = track_xform->ref_rot.log(); + track_xform->init_rot = rest.basis.get_rotation_quaternion(); track_xform->init_scale = rest.basis.get_scale(); } } @@ -667,8 +666,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { track_xform->init_loc = reset_anim->track_get_key_value(rt, 0); } break; case Animation::TYPE_ROTATION_3D: { - track_xform->ref_rot = reset_anim->track_get_key_value(rt, 0); - track_xform->init_rot = track_xform->ref_rot.log(); + track_xform->init_rot = reset_anim->track_get_key_value(rt, 0); } break; case Animation::TYPE_SCALE_3D: { track_xform->init_scale = reset_anim->track_get_key_value(rt, 0); @@ -1001,7 +999,7 @@ void AnimationTree::_process_graph(double p_delta) { if (t->process_pass != process_pass) { t->process_pass = process_pass; t->loc = Vector3(0, 0, 0); - t->rot = Quaternion(0, 0, 0, 0); + t->rot = Quaternion(0, 0, 0, 1); t->scale = Vector3(0, 0, 0); } double prev_time = time - delta; @@ -1097,7 +1095,7 @@ void AnimationTree::_process_graph(double p_delta) { if (t->process_pass != process_pass) { t->process_pass = process_pass; t->loc = Vector3(0, 0, 0); - t->rot = Quaternion(0, 0, 0, 0); + t->rot = Quaternion(0, 0, 0, 1); t->scale = Vector3(0, 0, 0); } double prev_time = time - delta; @@ -1144,7 +1142,7 @@ void AnimationTree::_process_graph(double p_delta) { continue; } a->rotation_track_interpolate(i, (double)a->get_length(), &rot[1]); - t->rot += (rot[1].log() - rot[0].log()) * blend; + t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized(); prev_time = 0; } } else { @@ -1154,7 +1152,7 @@ void AnimationTree::_process_graph(double p_delta) { continue; } a->rotation_track_interpolate(i, 0, &rot[1]); - t->rot += (rot[1].log() - rot[0].log()) * blend; + t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized(); prev_time = 0; } } @@ -1165,7 +1163,7 @@ void AnimationTree::_process_graph(double p_delta) { } a->rotation_track_interpolate(i, time, &rot[1]); - t->rot += (rot[1].log() - rot[0].log()) * blend; + t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized(); prev_time = !backward ? 0 : (double)a->get_length(); } else { @@ -1182,10 +1180,7 @@ void AnimationTree::_process_graph(double p_delta) { continue; } - if (signbit(rot.dot(t->ref_rot))) { - rot = -rot; - } - t->rot += (rot.log() - t->init_rot) * blend; + t->rot = (t->rot * Quaternion().slerp(t->init_rot.inverse() * rot, blend)).normalized(); } #endif // _3D_DISABLED } break; @@ -1196,7 +1191,7 @@ void AnimationTree::_process_graph(double p_delta) { if (t->process_pass != process_pass) { t->process_pass = process_pass; t->loc = Vector3(0, 0, 0); - t->rot = Quaternion(0, 0, 0, 0); + t->rot = Quaternion(0, 0, 0, 1); t->scale = Vector3(0, 0, 0); } double prev_time = time - delta; @@ -1585,7 +1580,6 @@ void AnimationTree::_process_graph(double p_delta) { case Animation::TYPE_POSITION_3D: { #ifndef _3D_DISABLED TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track); - t->rot = t->rot.exp(); if (t->root_motion) { Transform3D xform; |