mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Update AnimationPlayer in real-time when keyframe properties change
This commit is contained in:
parent
e53dc80f2f
commit
67a5932a4f
@ -120,12 +120,18 @@ bool AnimationTrackKeyEdit::_set(const StringName &p_name, const Variant &p_valu
|
||||
float val = p_value;
|
||||
float prev_val = animation->track_get_key_transition(track, key);
|
||||
setting = true;
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Change Transition"), UndoRedo::MERGE_ENDS);
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, val);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val);
|
||||
undo_redo->add_do_method(this, "_update_obj", animation);
|
||||
undo_redo->add_undo_method(this, "_update_obj", animation);
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
|
||||
setting = false;
|
||||
@ -177,12 +183,18 @@ bool AnimationTrackKeyEdit::_set(const StringName &p_name, const Variant &p_valu
|
||||
}
|
||||
|
||||
setting = true;
|
||||
|
||||
undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS);
|
||||
Variant prev = animation->track_get_key_value(track, key);
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, value);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, prev);
|
||||
undo_redo->add_do_method(this, "_update_obj", animation);
|
||||
undo_redo->add_undo_method(this, "_update_obj", animation);
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
|
||||
setting = false;
|
||||
@ -3281,6 +3293,11 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
|
||||
undo_redo->create_action(TTR("Change Animation Update Mode"));
|
||||
undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode);
|
||||
undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", track, animation->value_track_get_update_mode(track));
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
queue_redraw();
|
||||
|
||||
@ -3295,6 +3312,11 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
|
||||
undo_redo->create_action(TTR("Change Animation Interpolation Mode"));
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", track, animation->track_get_interpolation_type(track));
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
queue_redraw();
|
||||
} break;
|
||||
@ -3305,6 +3327,11 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
|
||||
undo_redo->create_action(TTR("Change Animation Loop Mode"));
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, animation->track_get_interpolation_loop_wrap(track));
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
queue_redraw();
|
||||
|
||||
@ -5643,6 +5670,14 @@ void AnimationTrackEditor::_move_selection_commit() {
|
||||
moving_selection = false;
|
||||
undo_redo->add_do_method(this, "_redraw_tracks");
|
||||
undo_redo->add_undo_method(this, "_redraw_tracks");
|
||||
|
||||
// Update key frame.
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
@ -7706,6 +7741,8 @@ void AnimationTrackKeyEditEditor::_time_edit_exited() {
|
||||
undo_redo->add_do_method(ate, "_select_at_anim", animation, track, new_time);
|
||||
undo_redo->add_undo_method(ate, "_select_at_anim", animation, track, key_data_cache.time);
|
||||
}
|
||||
undo_redo->add_do_method(ape, "_animation_update_key_frame");
|
||||
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
|
||||
}
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
@ -1413,6 +1413,12 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_timel
|
||||
_seek_value_changed(p_pos, p_timeline_only);
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_update_key_frame() {
|
||||
if (player) {
|
||||
player->advance(0);
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
String current = _get_current();
|
||||
|
||||
@ -1874,6 +1880,7 @@ bool AnimationPlayerEditor::_validate_tracks(const Ref<Animation> p_anim) {
|
||||
void AnimationPlayerEditor::_bind_methods() {
|
||||
// Needed for UndoRedo.
|
||||
ClassDB::bind_method(D_METHOD("_animation_player_changed"), &AnimationPlayerEditor::_animation_player_changed);
|
||||
ClassDB::bind_method(D_METHOD("_animation_update_key_frame"), &AnimationPlayerEditor::_animation_update_key_frame);
|
||||
ClassDB::bind_method(D_METHOD("_start_onion_skinning"), &AnimationPlayerEditor::_start_onion_skinning);
|
||||
ClassDB::bind_method(D_METHOD("_stop_onion_skinning"), &AnimationPlayerEditor::_stop_onion_skinning);
|
||||
|
||||
|
@ -216,6 +216,7 @@ class AnimationPlayerEditor : public VBoxContainer {
|
||||
|
||||
void _animation_key_editor_seek(float p_pos, bool p_timeline_only = false, bool p_update_position_only = false);
|
||||
void _animation_key_editor_anim_len_changed(float p_len);
|
||||
void _animation_update_key_frame();
|
||||
|
||||
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
|
||||
void _animation_tool_menu(int p_option);
|
||||
|
Loading…
Reference in New Issue
Block a user