Cleaned up logic in Tween::_tween_process(), fixes #9187

This commit is contained in:
cryptonaut 2017-08-29 00:08:59 -07:00
parent 28c85922b1
commit 023b68542f
1 changed files with 10 additions and 14 deletions

View File

@ -560,12 +560,16 @@ void Tween::_tween_process(float p_delta) {
switch (data.type) { switch (data.type) {
case INTER_PROPERTY: case INTER_PROPERTY:
case INTER_METHOD: case INTER_METHOD: {
break; Variant result = _run_equation(data);
emit_signal("tween_step", object, data.key, data.elapsed, result);
_apply_tween_value(data, result);
if (data.finish)
_apply_tween_value(data, data.final_val);
} break;
case INTER_CALLBACK: case INTER_CALLBACK:
if (data.finish) { if (data.finish) {
Variant::CallError error;
if (data.call_deferred) { if (data.call_deferred) {
switch (data.args) { switch (data.args) {
@ -588,8 +592,8 @@ void Tween::_tween_process(float p_delta) {
object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]); object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
break; break;
} }
} else { } else {
Variant::CallError error;
Variant *arg[5] = { Variant *arg[5] = {
&data.arg[0], &data.arg[0],
&data.arg[1], &data.arg[1],
@ -599,19 +603,11 @@ void Tween::_tween_process(float p_delta) {
}; };
object->call(data.key, (const Variant **)arg, data.args, error); object->call(data.key, (const Variant **)arg, data.args, error);
} }
if (!repeat)
call_deferred("_remove", object, data.key, true);
} }
continue; break;
} }
Variant result = _run_equation(data);
emit_signal("tween_step", object, data.key, data.elapsed, result);
_apply_tween_value(data, result);
if (data.finish) { if (data.finish) {
_apply_tween_value(data, data.final_val);
emit_signal("tween_completed", object, data.key); emit_signal("tween_completed", object, data.key);
// not repeat mode, remove completed action // not repeat mode, remove completed action
if (!repeat) if (!repeat)