Merge pull request #72096 from TokageItLab/spamspamspam
Fix spamming audio preview and cleanup process in `AnimationPlayer/Tree`
This commit is contained in:
commit
b29cd0699a
|
@ -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());
|
ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count());
|
||||||
|
|
||||||
Animation *a = p_anim->animation.operator->();
|
Animation *a = p_anim->animation.operator->();
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
|
bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
|
||||||
|
#endif // TOOLS_ENABLED
|
||||||
bool backward = signbit(p_delta);
|
bool backward = signbit(p_delta);
|
||||||
|
|
||||||
for (int i = 0; i < a->get_track_count(); i++) {
|
for (int i = 0; i < a->get_track_count(); i++) {
|
||||||
|
@ -745,11 +747,13 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Animation::TYPE_METHOD: {
|
case Animation::TYPE_METHOD: {
|
||||||
if (!nc->node || is_stopping) {
|
#ifdef TOOLS_ENABLED
|
||||||
|
if (!can_call) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!p_is_current) {
|
#endif // TOOLS_ENABLED
|
||||||
break;
|
if (!p_is_current || !nc->node || is_stopping) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> indices;
|
List<int> indices;
|
||||||
|
@ -772,17 +776,13 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
|
||||||
for (int &E : indices) {
|
for (int &E : indices) {
|
||||||
StringName method = a->method_track_get_name(i, E);
|
StringName method = a->method_track_get_name(i, E);
|
||||||
Vector<Variant> params = a->method_track_get_params(i, E);
|
Vector<Variant> params = a->method_track_get_params(i, E);
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (!nc->node->has_method(method)) {
|
if (!nc->node->has_method(method)) {
|
||||||
ERR_PRINT("Invalid method call '" + method + "'. '" + a->get_name() + "' at node '" + get_path() + "'.");
|
ERR_PRINT("Invalid method call '" + method + "'. '" + a->get_name() + "' at node '" + get_path() + "'.");
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
} break;
|
||||||
case Animation::TYPE_BEZIER: {
|
case Animation::TYPE_BEZIER: {
|
||||||
|
@ -813,7 +813,11 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_seeked) {
|
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);
|
int idx = a->track_find_key(i, p_time);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -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.
|
// 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();
|
bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
|
||||||
|
#endif // TOOLS_ENABLED
|
||||||
for (const AnimationNode::AnimationState &as : state.animation_states) {
|
for (const AnimationNode::AnimationState &as : state.animation_states) {
|
||||||
Ref<Animation> a = as.animation;
|
Ref<Animation> a = as.animation;
|
||||||
double time = as.time;
|
double time = as.time;
|
||||||
|
@ -1408,6 +1409,11 @@ void AnimationTree::_process_graph(double p_delta) {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Animation::TYPE_METHOD: {
|
case Animation::TYPE_METHOD: {
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
if (!can_call) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // TOOLS_ENABLED
|
||||||
TrackCacheMethod *t = static_cast<TrackCacheMethod *>(track);
|
TrackCacheMethod *t = static_cast<TrackCacheMethod *>(track);
|
||||||
|
|
||||||
if (seeked) {
|
if (seeked) {
|
||||||
|
@ -1417,20 +1423,16 @@ void AnimationTree::_process_graph(double p_delta) {
|
||||||
}
|
}
|
||||||
StringName method = a->method_track_get_name(i, idx);
|
StringName method = a->method_track_get_name(i, idx);
|
||||||
Vector<Variant> params = a->method_track_get_params(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 {
|
} else {
|
||||||
List<int> indices;
|
List<int> indices;
|
||||||
a->track_get_key_indices_in_range(i, time, delta, &indices, looped_flag);
|
a->track_get_key_indices_in_range(i, time, delta, &indices, looped_flag);
|
||||||
for (int &F : indices) {
|
for (int &F : indices) {
|
||||||
StringName method = a->method_track_get_name(i, F);
|
StringName method = a->method_track_get_name(i, F);
|
||||||
Vector<Variant> params = a->method_track_get_params(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;
|
} break;
|
||||||
case Animation::TYPE_BEZIER: {
|
case Animation::TYPE_BEZIER: {
|
||||||
TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track);
|
TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track);
|
||||||
|
@ -1444,7 +1446,6 @@ void AnimationTree::_process_graph(double p_delta) {
|
||||||
TrackCacheAudio *t = static_cast<TrackCacheAudio *>(track);
|
TrackCacheAudio *t = static_cast<TrackCacheAudio *>(track);
|
||||||
|
|
||||||
if (seeked) {
|
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);
|
int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue