diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-26 09:51:54 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-26 09:51:54 +0100 |
commit | b29cd0699ab0f56b66421ab93ef5647ae17f80e8 (patch) | |
tree | d66bd35efd6a76ba47c94f551355cd9c50c5923a | |
parent | 62188842dab6466efc509a7f26d9f5abe6750344 (diff) | |
parent | 4e56c2b0b00ad7fbb5637ea4f5c4300625b841a9 (diff) |
Merge pull request #72096 from TokageItLab/spamspamspam
Fix spamming audio preview and cleanup process in `AnimationPlayer/Tree`
-rw-r--r-- | scene/animation/animation_player.cpp | 22 | ||||
-rw-r--r-- | scene/animation/animation_tree.cpp | 17 |
2 files changed, 22 insertions, 17 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 047997ca09..e66eb8c1de 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -473,7 +473,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count()); Animation *a = p_anim->animation.operator->(); +#ifdef TOOLS_ENABLED bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); +#endif // TOOLS_ENABLED bool backward = signbit(p_delta); for (int i = 0; i < a->get_track_count(); i++) { @@ -745,11 +747,13 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } break; case Animation::TYPE_METHOD: { - if (!nc->node || is_stopping) { +#ifdef TOOLS_ENABLED + if (!can_call) { continue; } - if (!p_is_current) { - break; +#endif // TOOLS_ENABLED + if (!p_is_current || !nc->node || is_stopping) { + continue; } List<int> indices; @@ -772,16 +776,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double for (int &E : indices) { StringName method = a->method_track_get_name(i, E); Vector<Variant> params = a->method_track_get_params(i, E); - #ifdef DEBUG_ENABLED if (!nc->node->has_method(method)) { ERR_PRINT("Invalid method call '" + method + "'. '" + a->get_name() + "' at node '" + get_path() + "'."); } #endif - - if (can_call) { - _call_object(nc->node, method, params, method_call_mode == ANIMATION_METHOD_CALL_DEFERRED); - } + _call_object(nc->node, method, params, method_call_mode == ANIMATION_METHOD_CALL_DEFERRED); } } break; @@ -813,7 +813,11 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } if (p_seeked) { - //find whatever should be playing +#ifdef TOOLS_ENABLED + if (!can_call) { + continue; // To avoid spamming the preview in editor. + } +#endif // TOOLS_ENABLED int idx = a->track_find_key(i, p_time); if (idx < 0) { continue; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 077a5696bb..91b6f5fdd4 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -1015,8 +1015,9 @@ void AnimationTree::_process_graph(double p_delta) { // Apply value/transform/blend/bezier blends to track caches and execute method/audio/animation tracks. { +#ifdef TOOLS_ENABLED bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); - +#endif // TOOLS_ENABLED for (const AnimationNode::AnimationState &as : state.animation_states) { Ref<Animation> a = as.animation; double time = as.time; @@ -1408,6 +1409,11 @@ void AnimationTree::_process_graph(double p_delta) { } break; case Animation::TYPE_METHOD: { +#ifdef TOOLS_ENABLED + if (!can_call) { + return; + } +#endif // TOOLS_ENABLED TrackCacheMethod *t = static_cast<TrackCacheMethod *>(track); if (seeked) { @@ -1417,18 +1423,14 @@ void AnimationTree::_process_graph(double p_delta) { } StringName method = a->method_track_get_name(i, idx); Vector<Variant> params = a->method_track_get_params(i, idx); - if (can_call) { - _call_object(t->object, method, params, false); - } + _call_object(t->object, method, params, false); } else { List<int> indices; a->track_get_key_indices_in_range(i, time, delta, &indices, looped_flag); for (int &F : indices) { StringName method = a->method_track_get_name(i, F); Vector<Variant> params = a->method_track_get_params(i, F); - if (can_call) { - _call_object(t->object, method, params, true); - } + _call_object(t->object, method, params, true); } } } break; @@ -1444,7 +1446,6 @@ void AnimationTree::_process_graph(double p_delta) { TrackCacheAudio *t = static_cast<TrackCacheAudio *>(track); if (seeked) { - //find whatever should be playing int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT); if (idx < 0) { continue; |