-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Reset animation on playback stop #33733
Conversation
@akien-mga do you see any danger in merging this? |
Yes, two things I'm not sure about:
|
@KoBeWi Is this still desired? If so, it needs to be rebased on the latest master branch. |
228b0e2
to
21432d0
Compare
Needs a rebase to fix CI. But note that this is potentially superseded by #44345, we need a design decision on how we want the API to be like for animation playback (both AnimationPlayer and AnimatedSprite). From what I remember #44345 was discussed in a PR review meeting and had mostly consensus, so we might want to re-review that and possibly close this PR while merging #44345. This PR might still be relevant as a simpler fix for |
Dismissing review because, although at first this looked good to me, I realized it's not mature yet.
21432d0
to
7b76e6f
Compare
@akien-mga , no, this is never wanted. This is the dirtiest behaviour I can imagine. You are mixing to very different commands here: Pause and Stop. Pause, pauses (timestamp stays where it is) stop stops playback (resets timestamp). |
I assume that something like So, it should be ensured that only certain types (Position3D/Rotation3D/Scale3D/BlendShape/Value(except Discrete)/Bezier) of tracks are updated when reset. |
7b76e6f
to
823773b
Compare
Rebased. The animation process code is so complex that I couldn't think of how to reasonably implement "internal seeking", so I just added a bool called |
Playback avoidance is needed not only in TYPE_METHOD but also in TYPE_AUDIO and TYPE_ANIMATION. So, it is better to do |
I'm already stopping TYPE_AUDIO, forgot about TYPE_ANIMATION. |
823773b
to
6689d26
Compare
6689d26
to
7137cbf
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.
The reset option should be propagated to the SubAnimationPlayer of the AnimationPlaybackTrack.
void AnimationPlayer::_stop_playing_caches() {
for (TrackNodeCache *E : playing_caches) {
if (E->node && E->audio_playing) {
E->node->call(SNAME("stop"));
}
if (E->node && E->animation_playing) {
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(E->node);
if (!player) {
continue;
}
player->stop();
}
}
playing_caches.clear();
}
So, it should be fixed to like this:
void AnimationPlayer::_stop_playing_caches(bool p_reset) {
~~
if (p_reset) {
player->stop();
} else {
player->pause();
}
~~
}
Tested, looks fine except for the above issue. I sent a PR to apply the pause() and stop() separately to AnimationPlayerEditor as #71321. I will rebase that PR as soon as this PR is merged first. This is a note to myself: considering this fix, I will need to divide the type of seek into three types in godotengine/godot-proposals#5972. |
7137cbf
to
4668a18
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.
LGTM. I agree with this change, also it is consistent with tween.
Thanks! |
Hi. Does this fix imply that property values tracks will have their 0 time values reapplied when an animation is stopped? How does it make sense to update tracks when the animation player is 'stopped'? How is the end user supposed to guess which tracks will be updated when we 'stop'? What is being 'fixed' here? For a prettier editor scenario, you are breaking user scenarios in code. stop() is used extensively in code, reliant on the behavior that the animation player has stopped updating. stop() should simply NOT cause any updates. conceptually, how can it? |
Fixes #27499