summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-03 11:24:48 +0100
committerGitHub <noreply@github.com>2018-01-03 11:24:48 +0100
commit48962db5b4832f1643817f1e7eeee98d1bfd9af1 (patch)
treed0ef4ab69d9b4bbf0895883b015958510a6a0c9b /scene/animation
parentfa9320cfc6a6662e6dd5692a5db4a2ad1c5947fc (diff)
parent9c3fbfc9db321ccdc263d71d2e161f651a9e674d (diff)
Merge pull request #15132 from RandomShaper/fix-multiple-finish
Fix AnimationPlayer redundantly signaling finish
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_player.cpp21
-rw-r--r--scene/animation/animation_player.h1
2 files changed, 14 insertions, 8 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 6463180d9e..bac95c6cca 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -547,12 +547,14 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
if (!backwards && cd.pos <= len && next_pos == len /*&& playback.blend.empty()*/) {
//playback finished
- end_notify = true;
+ end_reached = true;
+ end_notify = cd.pos < len; // Notify only if not already at the end
}
if (backwards && cd.pos >= 0 && next_pos == 0 /*&& playback.blend.empty()*/) {
//playback finished
- end_notify = true;
+ end_reached = true;
+ end_notify = cd.pos > 0; // Notify only if not already at the beginning
}
}
@@ -679,24 +681,26 @@ void AnimationPlayer::_animation_process(float p_delta) {
if (playback.current.from) {
+ end_reached = false;
end_notify = false;
_animation_process2(p_delta);
_animation_update_transforms();
- if (end_notify) {
+ if (end_reached) {
if (queued.size()) {
String old = playback.assigned;
play(queued.front()->get());
String new_name = playback.assigned;
queued.pop_front();
- end_notify = false;
- emit_signal(SceneStringNames::get_singleton()->animation_changed, old, new_name);
+ if (end_notify)
+ emit_signal(SceneStringNames::get_singleton()->animation_changed, old, new_name);
} else {
//stop();
playing = false;
_set_process(false);
- end_notify = false;
- emit_signal(SceneStringNames::get_singleton()->animation_finished, playback.assigned);
+ if (end_notify)
+ emit_signal(SceneStringNames::get_singleton()->animation_finished, playback.assigned);
}
+ end_reached = false;
}
} else {
@@ -954,7 +958,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
c.current.speed_scale = p_custom_scale;
c.assigned = p_name;
- if (!end_notify)
+ if (!end_reached)
queued.clear();
_set_process(true); // always process when starting an animation
playing = true;
@@ -1348,6 +1352,7 @@ AnimationPlayer::AnimationPlayer() {
cache_update_size = 0;
cache_update_prop_size = 0;
speed_scale = 1;
+ end_reached = false;
end_notify = false;
animation_process_mode = ANIMATION_PROCESS_IDLE;
processing = false;
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 57c658e054..40a7252528 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -205,6 +205,7 @@ private:
List<StringName> queued;
+ bool end_reached;
bool end_notify;
String autoplay;