Merge pull request #73120 from TokageItLab/fix-transition-reset-fade

Fix remaining fade doesn't clear when reset in AnimationNodeTransition
This commit is contained in:
Rémi Verschelde 2023-02-11 22:03:35 +01:00
commit 9075d5e932
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 13 additions and 4 deletions

View File

@ -826,6 +826,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
bool switched = false;
bool restart = false;
bool clear_remaining_fade = false;
if (pending_update) {
if (cur_current_index < 0 || cur_current_index >= get_input_count()) {
@ -843,6 +844,10 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
pending_update = false;
}
if (p_time == 0 && p_seek && !p_is_external_seeking) {
clear_remaining_fade = true; // Reset occurs.
}
if (!cur_transition_request.is_empty()) {
int new_idx = find_input(cur_transition_request);
if (new_idx >= 0) {
@ -850,10 +855,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
if (allow_transition_to_self) {
// Transition to same state.
restart = input_data[cur_current_index].reset;
cur_prev_xfading = 0;
set_parameter(prev_xfading, 0);
cur_prev_index = -1;
set_parameter(prev_index, -1);
clear_remaining_fade = true;
}
} else {
switched = true;
@ -870,6 +872,13 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
set_parameter(transition_request, cur_transition_request);
}
if (clear_remaining_fade) {
cur_prev_xfading = 0;
set_parameter(prev_xfading, 0);
cur_prev_index = -1;
set_parameter(prev_index, -1);
}
// Special case for restart.
if (restart) {
set_parameter(time, 0);