1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Handle internal seek on AnimationPlayer to process discrete correctly

This commit is contained in:
Silc Lizard (Tokage) Renew
2024-07-16 14:38:56 +09:00
parent 97b8ad1af0
commit 98dbd869c5
3 changed files with 25 additions and 16 deletions

View File

@@ -248,7 +248,7 @@ void AnimationPlayerEditor::_play_from_pressed() {
player->clear_caches(); //so it won't blend with itself
}
ERR_FAIL_COND_EDMSG(!_validate_tracks(player->get_animation(current)), "Animation tracks may have any invalid key, abort playing.");
player->seek(time, true, true);
player->seek_internal(time, true, true, true);
player->play(current);
}
@@ -286,7 +286,7 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
player->clear_caches(); //so it won't blend with itself
}
ERR_FAIL_COND_EDMSG(!_validate_tracks(player->get_animation(current)), "Animation tracks may have any invalid key, abort playing.");
player->seek(time, true, true);
player->seek_internal(time, true, true, true);
player->play_backwards(current);
}
@@ -1295,7 +1295,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_timeline_o
pos = CLAMP(pos, 0, (double)anim->get_length() - CMP_EPSILON2); // Hack: Avoid fposmod with LOOP_LINEAR.
if (!p_timeline_only && anim.is_valid()) {
player->seek(pos, true, true);
player->seek_internal(pos, true, true, false);
}
track_editor->set_anim_pos(pos);
@@ -1706,7 +1706,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2_step_prepare(int p_step_offs
bool valid = anim->get_loop_mode() != Animation::LOOP_NONE || (pos >= 0 && pos <= anim->get_length());
onion.captures_valid[p_capture_idx] = valid;
if (valid) {
player->seek(pos, true, true);
player->seek_internal(pos, true, true, false);
OS::get_singleton()->get_main_loop()->process(0);
// This is the key: process the frame and let all callbacks/updates/notifications happen
// so everything (transforms, skeletons, etc.) is up-to-date visually.
@@ -1763,7 +1763,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2_epilog() {
// backed by a proper reset animation will work correctly with onion
// skinning and the possibility to restore the values mentioned in the
// first point above is gone. Still good enough.
player->seek(onion.temp.anim_player_position, true, true);
player->seek_internal(onion.temp.anim_player_position, true, true, false);
player->restore(onion.temp.anim_values_backup);
// Restore state of main editors.