summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilc Renew <tokage.it.lab@gmail.com>2023-02-12 04:12:15 +0900
committerSilc Renew <tokage.it.lab@gmail.com>2023-02-12 04:12:15 +0900
commit2a0beb1ef36db00006c441e8038201a798917b37 (patch)
tree25b337a8a21c2b47754e0ab68d562168e8009985
parent44b41ded82229ca7614403f74234a4282002458b (diff)
Fix remaining fade doesn't clear when reset in AnimationNodeTransition
-rw-r--r--scene/animation/animation_blend_tree.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 3567738366..8cd96decea 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -825,6 +825,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()) {
@@ -842,6 +843,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) {
@@ -849,10 +854,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;
@@ -869,6 +871,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);