diff options
author | Juan Linietsky <juan@godotengine.org> | 2018-06-27 16:30:48 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2018-06-27 16:30:48 -0300 |
commit | 9bab5134cfd4f0095545ae58fcf6a10dc07dc7d1 (patch) | |
tree | 1d5d15103cde49a22592b90c93b3cb80f53db7dd /scene/animation | |
parent | 68f7cf13c7326c077cc6ff8a6a267ae2610c4519 (diff) |
The way multiple quaternions being slerped was not good, changed approach to one that seems to work better.
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_tree.cpp | 10 | ||||
-rw-r--r-- | scene/animation/animation_tree.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 62f2726f75..1e583db676 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -813,6 +813,7 @@ void AnimationTree::_process_graph(float p_delta) { t->process_pass = process_pass; t->loc = Vector3(); t->rot = Quat(); + t->rot_blend_accum = 0; t->scale = Vector3(); } @@ -876,7 +877,14 @@ void AnimationTree::_process_graph(float p_delta) { continue; t->loc = t->loc.linear_interpolate(loc, blend); - t->rot = t->rot.slerp(rot, blend); + if (t->rot_blend_accum==0) { + t->rot = rot; + t->rot_blend_accum = blend; + } else { + float rot_total = t->rot_blend_accum + blend; + t->rot = rot.slerp(t->rot, t->rot_blend_accum / rot_total).normalized(); + t->rot_blend_accum = rot_total; + } t->scale = t->scale.linear_interpolate(scale, blend); } diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 41d67118c1..540c36437a 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -161,6 +161,7 @@ private: int bone_idx; Vector3 loc; Quat rot; + float rot_blend_accum; Vector3 scale; TrackCacheTransform() { |