Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop state check in AnimationStateMachine #79141

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scene/animation/animation_node_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,18 +901,20 @@ bool AnimationNodeStateMachinePlayback::_transition_to_next_recursive(AnimationT
bool is_state_changed = false;

NextInfo next;
StringName transition_start = current;
Vector<StringName> transition_path;
bruvzg marked this conversation as resolved.
Show resolved Hide resolved
transition_path.push_back(current);
while (true) {
next = _find_next(p_tree, p_state_machine);
if (next.node == transition_start) {
is_state_changed = false;
break; // Maybe infinity loop, do noting more.
if (transition_path.has(next.node)) {
WARN_PRINT_ONCE_ED("AnimationNodeStateMachinePlayback: " + base_path + "playback aborts the transition by detecting one or more looped transitions in the same frame to prevent to infinity loop. You may need to check the transition settings.");
break; // Maybe infinity loop, do nothing more.
}

if (!_can_transition_to_next(p_tree, p_state_machine, next, p_test_only)) {
break; // Finish transition.
}

transition_path.push_back(next.node);
is_state_changed = true;

// Setting for fading.
Expand Down