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

Check the seeking if it is processed immediately after playback as a special case #85366

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions scene/animation/animation_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void AnimationPlayer::_notification(int p_what) {
if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
set_active(true);
play(autoplay);
seek(0, true);
_check_immediately_after_start();
}
} break;
}
Expand Down Expand Up @@ -522,8 +522,9 @@ void AnimationPlayer::seek(double p_time, bool p_update, bool p_update_only) {
return;
}

playback.current.pos = p_time;
_check_immediately_after_start();

playback.current.pos = p_time;
if (!playback.current.from) {
if (playback.assigned) {
ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned));
Expand All @@ -534,7 +535,6 @@ void AnimationPlayer::seek(double p_time, bool p_update, bool p_update_only) {
}
}

playback.started = false; // Start has already gone by seeking, delta does not need to be 0 in the internal process.
playback.seeked = true;
if (p_update) {
_process_animation(0, p_update_only);
Expand All @@ -543,10 +543,16 @@ void AnimationPlayer::seek(double p_time, bool p_update, bool p_update_only) {
}

void AnimationPlayer::advance(double p_time) {
playback.started = false; // Start has already gone by advancing, delta does not need to be 0 in the internal process.
_check_immediately_after_start();
AnimationMixer::advance(p_time);
}

void AnimationPlayer::_check_immediately_after_start() {
if (playback.started) {
_process_animation(0); // Force process current key for Discrete/Method/Audio/AnimationPlayback. Then, started flag is cleared.
}
}

bool AnimationPlayer::is_valid() const {
return (playback.current.from);
}
Expand Down
1 change: 1 addition & 0 deletions scene/animation/animation_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class AnimationPlayer : public AnimationMixer {
void _process_playback_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_started, bool p_is_current = false);
void _blend_playback_data(double p_delta, bool p_started);
void _stop_internal(bool p_reset, bool p_keep_state);
void _check_immediately_after_start();

bool playing = false;

Expand Down
Loading