diff options
author | ScottVMariotte <ScottjMariotte@gmail.com> | 2022-04-14 14:28:42 -0400 |
---|---|---|
committer | ScottVMariotte <ScottjMariotte@gmail.com> | 2022-04-14 18:18:00 -0400 |
commit | c526ee6683b74a8e0b283b1630dd29c5280aae19 (patch) | |
tree | c5905f2ff96bea129a52a7ff6bde3da27192b22d /scene/animation | |
parent | 97a8d0785700d4c89a58bac442651725d84b5e83 (diff) |
Replaced loops_current with end_loop
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_node_state_machine.cpp | 16 | ||||
-rw-r--r-- | scene/animation/animation_node_state_machine.h | 2 |
2 files changed, 5 insertions, 13 deletions
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 5ea7f4b7d9..4f94ec3584 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -185,8 +185,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta 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 target_pos = p_state_machine->states[p_travel].position; @@ -352,7 +350,6 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s 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; - loops_current = 0; } if (!p_state_machine->states.has(current)) { @@ -388,12 +385,8 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s } { //advance and loop check - float next_pos = len_current - rem; - - if (next_pos < pos_current) { - loops_current++; - } + end_loop = next_pos < pos_current; pos_current = next_pos; //looped } @@ -443,15 +436,15 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s bool goto_next = false; if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_AT_END) { - goto_next = next_xfade >= (len_current - pos_current) || loops_current > 0; - if (loops_current > 0) { + goto_next = next_xfade >= (len_current - pos_current) || end_loop; + if (end_loop) { next_xfade = 0; } } else { 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) { //time to fade, baby @@ -478,7 +471,6 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s } rem = len_current; //so it does not show 0 on transition - loops_current = 0; } } diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h index 3bae0fcffa..96add7f538 100644 --- a/scene/animation/animation_node_state_machine.h +++ b/scene/animation/animation_node_state_machine.h @@ -97,7 +97,7 @@ class AnimationNodeStateMachinePlayback : public Resource { float len_current = 0.0; float pos_current = 0.0; - int loops_current = 0; + bool end_loop = false; StringName current; |