diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-11-23 10:25:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-23 10:25:19 +0100 |
commit | a8a88194a5cf5849d421aaec05beddbc437ebbcd (patch) | |
tree | bbc4b44330383e0ba856a3cdd27f98b07c27ae3c | |
parent | 3791872c65bf4650464a4fdd7cf692f611648668 (diff) | |
parent | dce3e07fb20c6f011ce29732f63b6ac04aac92a9 (diff) | |
download | redot-engine-a8a88194a5cf5849d421aaec05beddbc437ebbcd.tar.gz |
Merge pull request #68993 from TokageItLab/fix-anim-blending-for-DISCRETE-mode
Fix animation blending for value track `UPDATE_DISCRETE` and `UPDATE_TRIGGER` mode
-rw-r--r-- | scene/animation/animation_tree.cpp | 6 | ||||
-rw-r--r-- | scene/animation/animation_tree.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 8b6d6e96b2..99d450fa5b 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -586,6 +586,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { track_value->object = child; } + track_value->is_discrete = anim->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE || anim->value_track_get_update_mode(i) == Animation::UPDATE_TRIGGER; track_value->is_using_angle = anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_LINEAR_ANGLE || anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_CUBIC_ANGLE; track_value->subpath = leftover_path; @@ -800,6 +801,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { } else if (track_cache_type == Animation::TYPE_VALUE) { // If it has at least one angle interpolation, it also uses angle interpolation for blending. TrackCacheValue *track_value = memnew(TrackCacheValue); + track_value->is_discrete |= anim->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE || anim->value_track_get_update_mode(i) == Animation::UPDATE_TRIGGER; track_value->is_using_angle |= anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_LINEAR_ANGLE || anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_CUBIC_ANGLE; } @@ -1658,6 +1660,10 @@ void AnimationTree::_process_graph(double p_delta) { case Animation::TYPE_VALUE: { TrackCacheValue *t = static_cast<TrackCacheValue *>(track); + if (t->is_discrete) { + break; // Don't overwrite the value set by UPDATE_DISCRETE or UPDATE_TRIGGER. + } + if (t->init_value.get_type() == Variant::BOOL) { t->object->set_indexed(t->subpath, t->value.operator real_t() >= 0.5); } else { diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 493cd894d0..84d0a8190a 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -232,6 +232,7 @@ private: Variant init_value; Variant value; Vector<StringName> subpath; + bool is_discrete = false; bool is_using_angle = false; TrackCacheValue() { type = Animation::TYPE_VALUE; } }; |