-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Avoid infinite recursion between AnimationPlayer and AnimationMixer #98704
base: master
Are you sure you want to change the base?
Avoid infinite recursion between AnimationPlayer and AnimationMixer #98704
Conversation
8dcc11a
to
004a24a
Compare
It looks like the patch is too specialized for special cases IMO. How about separating set_current_animation into internal and exposed methods, and not allowing the exposed method to have an empty animation name? |
004a24a
to
dd9d0b0
Compare
@TokageItLab I modified the pr to apply the changes u suggested, can you check again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a clean way of fixing the issue.
I do have one concern. Looking at the summary of the issue #98076, does it only occur with an empty character and not when “[stop]”
is set? If we can confirm that, I think this can be merged.
dd9d0b0
to
ee9d0cc
Compare
Indeed the |
scene/animation/animation_player.cpp
Outdated
@@ -942,6 +936,19 @@ void AnimationPlayer::_rename_animation(const StringName &p_from_name, const Str | |||
} | |||
} | |||
|
|||
void AnimationPlayer::_set_current_animation(const String &p_animation) { | |||
if (p_animation == "[stop]" || p_animation.is_empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (p_animation == "[stop]" || p_animation.is_empty()) { | |
if (p_animation.is_empty() || p_animation == "[stop]") { |
Prefer putting the cheaper condition first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…t to an empty string
ee9d0cc
to
4f386a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed the ["stop"] also triggers the issue
In that case, we need to think about a different approach. This is because a set of "[stop]"
could be called from the inspector.
BTW, is it a problem if stop() is called in a method track? How about a different approach, such as calling clear_cache()
with deferred inside stop()
?
Nothing happens, no crash but also the animation don't stop. |
In theory
AnimationPlayer.current_animation
shouldn't be setted directly but in normal cases that don't cause any problem unless the animation key setcurrent_animation
to an empty string, in this case will start an infinite recursion betweenAnimationPlayer
callingAnimationMixer::_blend_process
andAnimationMixer
setting the current animation to a empty string which will never stop until the engine crashes. This fix makesAnimationMixer
ignore these animation keys (that would do nothing anyways) and avoid the crash.Fix: #98076