summaryrefslogtreecommitdiff
path: root/scene/animation/animation_blend_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/animation_blend_tree.cpp')
-rw-r--r--scene/animation/animation_blend_tree.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 3567738366..5e75bd7722 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -351,14 +351,15 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_is_exter
}
real_t blend;
- bool use_fade_in = fade_in > 0;
+ bool use_blend = fade_in > 0;
if (cur_time < fade_in) {
- if (use_fade_in) {
+ if (use_blend) {
blend = cur_time / fade_in;
} else {
blend = 0; // Should not happen.
}
} else if (!do_start && cur_remaining <= fade_out) {
+ use_blend = true;
if (fade_out > 0) {
blend = (cur_remaining / fade_out);
} else {
@@ -371,7 +372,7 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_is_exter
double main_rem = 0.0;
if (mix == MIX_MODE_ADD) {
main_rem = blend_input(0, p_time, p_seek, p_is_external_seeking, 1.0, FILTER_IGNORE, sync);
- } else if (use_fade_in) {
+ } else if (use_blend) {
main_rem = blend_input(0, p_time, p_seek, p_is_external_seeking, 1.0 - blend, FILTER_BLEND, sync); // Unlike below, processing this edge is a corner case.
}
double os_rem = blend_input(1, os_seek ? cur_time : p_time, os_seek, p_is_external_seeking, Math::is_zero_approx(blend) ? CMP_EPSILON : blend, FILTER_PASS, true); // Blend values must be more than CMP_EPSILON to process discrete keys in edge.
@@ -825,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()) {
@@ -842,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) {
@@ -849,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;
@@ -869,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);