summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_player.cpp21
-rw-r--r--scene/animation/animation_player.h1
-rw-r--r--scene/animation/tween.cpp85
3 files changed, 53 insertions, 54 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;
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 2f30337cb8..1711fbffee 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -561,57 +561,50 @@ void Tween::_tween_process(float p_delta) {
data.finish = true;
}
- switch (data.type) {
- case INTER_PROPERTY:
- case INTER_METHOD: {
- Variant result = _run_equation(data);
- emit_signal("tween_step", object, NodePath(Vector<StringName>(), data.key, false), data.elapsed, result);
- _apply_tween_value(data, result);
- if (data.finish)
- _apply_tween_value(data, data.final_val);
- } break;
-
- case INTER_CALLBACK:
- if (data.finish) {
- if (data.call_deferred) {
-
- switch (data.args) {
- case 0:
- object->call_deferred(data.key[0]);
- break;
- case 1:
- object->call_deferred(data.key[0], data.arg[0]);
- break;
- case 2:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1]);
- break;
- case 3:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2]);
- break;
- case 4:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3]);
- break;
- case 5:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
- break;
- }
- } else {
- Variant::CallError error;
- Variant *arg[5] = {
- &data.arg[0],
- &data.arg[1],
- &data.arg[2],
- &data.arg[3],
- &data.arg[4],
- };
- object->call(data.key[0], (const Variant **)arg, data.args, error);
+ if (data.type == INTER_CALLBACK) {
+ if (data.finish) {
+ if (data.call_deferred) {
+
+ switch (data.args) {
+ case 0:
+ object->call_deferred(data.key[0]);
+ break;
+ case 1:
+ object->call_deferred(data.key[0], data.arg[0]);
+ break;
+ case 2:
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1]);
+ break;
+ case 3:
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2]);
+ break;
+ case 4:
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3]);
+ break;
+ case 5:
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
+ break;
}
+ } else {
+ Variant::CallError error;
+ Variant *arg[5] = {
+ &data.arg[0],
+ &data.arg[1],
+ &data.arg[2],
+ &data.arg[3],
+ &data.arg[4],
+ };
+ object->call(data.key[0], (const Variant **)arg, data.args, error);
}
- break;
- default: {}
+ }
+ } else {
+ Variant result = _run_equation(data);
+ emit_signal("tween_step", object, NodePath(Vector<StringName>(), data.key, false), data.elapsed, result);
+ _apply_tween_value(data, result);
}
if (data.finish) {
+ _apply_tween_value(data, data.final_val);
emit_signal("tween_completed", object, NodePath(Vector<StringName>(), data.key, false));
// not repeat mode, remove completed action
if (!repeat)