Replaced loops_current with end_loop
(cherry picked from commit c526ee6683
)
This commit is contained in:
parent
2c28c41e10
commit
25ef0aaf3e
2 changed files with 7 additions and 15 deletions
|
@ -183,8 +183,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
|
||||||
return true; //nothing to do
|
return true; //nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
loops_current = 0; // reset loops, so fade does not happen immediately
|
|
||||||
|
|
||||||
Vector2 current_pos = p_state_machine->states[current].position;
|
Vector2 current_pos = p_state_machine->states[current].position;
|
||||||
Vector2 target_pos = p_state_machine->states[p_travel].position;
|
Vector2 target_pos = p_state_machine->states[p_travel].position;
|
||||||
|
|
||||||
|
@ -350,7 +348,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
|
||||||
|
|
||||||
len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false);
|
len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false);
|
||||||
pos_current = 0;
|
pos_current = 0;
|
||||||
loops_current = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p_state_machine->states.has(current)) {
|
if (!p_state_machine->states.has(current)) {
|
||||||
|
@ -386,12 +383,8 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
|
||||||
}
|
}
|
||||||
|
|
||||||
{ //advance and loop check
|
{ //advance and loop check
|
||||||
|
|
||||||
float next_pos = len_current - rem;
|
float next_pos = len_current - rem;
|
||||||
|
end_loop = next_pos < pos_current;
|
||||||
if (next_pos < pos_current) {
|
|
||||||
loops_current++;
|
|
||||||
}
|
|
||||||
pos_current = next_pos; //looped
|
pos_current = next_pos; //looped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,15 +434,15 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
|
||||||
bool goto_next = false;
|
bool goto_next = false;
|
||||||
|
|
||||||
if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_AT_END) {
|
if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_AT_END) {
|
||||||
goto_next = next_xfade >= (len_current - pos_current) || loops_current > 0;
|
goto_next = next_xfade >= (len_current - pos_current) || end_loop;
|
||||||
if (loops_current > 0) {
|
if (end_loop) {
|
||||||
next_xfade = 0;
|
next_xfade = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goto_next = fading_from == StringName();
|
goto_next = fading_from == StringName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goto_next) { //loops should be used because fade time may be too small or zero and animation may have looped
|
if (goto_next) { //end_loop should be used because fade time may be too small or zero and animation may have looped
|
||||||
|
|
||||||
if (next_xfade) {
|
if (next_xfade) {
|
||||||
//time to fade, baby
|
//time to fade, baby
|
||||||
|
@ -476,7 +469,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
|
||||||
}
|
}
|
||||||
|
|
||||||
rem = len_current; //so it does not show 0 on transition
|
rem = len_current; //so it does not show 0 on transition
|
||||||
loops_current = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,9 +95,9 @@ class AnimationNodeStateMachinePlayback : public Resource {
|
||||||
|
|
||||||
float len_total;
|
float len_total;
|
||||||
|
|
||||||
float len_current;
|
float len_current = 0.0;
|
||||||
float pos_current;
|
float pos_current = 0.0;
|
||||||
int loops_current;
|
bool end_loop = false;
|
||||||
|
|
||||||
StringName current;
|
StringName current;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue