diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-02-14 10:19:03 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-02-14 10:22:34 -0300 |
commit | 4a24ba6e77c7128e64dee31cf05f6960abdb8108 (patch) | |
tree | d826f5eb8284559d98e44514796c2fc3aeb9f4af /editor/animation_track_editor.cpp | |
parent | 6b184e4d3b4f02c3bb04fa7a36fe65176f89ec3f (diff) | |
download | redot-engine-4a24ba6e77c7128e64dee31cf05f6960abdb8108.tar.gz |
-Fixes to undo redo to avoid crash, closes #24251
-Changed Animation to have a special signal when tracks are changed, to avoid unnecesary track cache rebuilds in AnimationPlayer
-Added missing emit_changed whe modifying keys to Animation
-Changed AnimationPlayer to use the new refcounted connections instead of the previous hacky way to keep references
-Changed AnimationEditor to update the current track when keys are edited
-Fixed bug where undo/redo did not work with AnimationKeyEdit (was not being updated)
-Made sure UndoRedo does not mind deleted objects in undo/redo history, this would corrupt the history or clear it without need.
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 662137d60d..929d6c7642 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -45,18 +45,22 @@ class AnimationTrackKeyEdit : public Object { public: bool setting; - bool hidden; bool _hide_script_from_inspector() { return true; } + bool _dont_undo_redo() { + return true; + } + static void _bind_methods() { ClassDB::bind_method("_update_obj", &AnimationTrackKeyEdit::_update_obj); ClassDB::bind_method("_key_ofs_changed", &AnimationTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method("_hide_script_from_inspector", &AnimationTrackKeyEdit::_hide_script_from_inspector); ClassDB::bind_method("get_root_path", &AnimationTrackKeyEdit::get_root_path); + ClassDB::bind_method("_dont_undo_redo", &AnimationTrackKeyEdit::_dont_undo_redo); } //PopupDialog *ke_dialog; @@ -82,16 +86,13 @@ public: void _update_obj(const Ref<Animation> &p_anim) { if (setting) return; - if (hidden) - return; if (!(animation == p_anim)) return; + notify_change(); } void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) { - if (hidden) - return; if (!(animation == p_anim)) return; if (from != key_ofs) @@ -168,6 +169,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; @@ -191,6 +193,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -267,6 +270,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; if (change_notify_deserved) notify_change(); @@ -286,6 +290,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -301,6 +306,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -316,6 +322,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -335,6 +342,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -350,6 +358,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -365,6 +374,7 @@ public: undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); undo_redo->commit_action(); + setting = false; return true; } @@ -639,6 +649,8 @@ public: PropertyInfo hint; NodePath base; + AnimationTrackEditor *track_editor; + void notify_change() { _change_notify(); @@ -649,11 +661,11 @@ public: } AnimationTrackKeyEdit() { - hidden = true; key_ofs = 0; track = -1; setting = false; root_path = NULL; + track_editor = NULL; } }; @@ -3414,6 +3426,14 @@ void AnimationTrackEditor::_update_tracks() { void AnimationTrackEditor::_animation_changed() { + if (key_edit && key_edit->setting) { + //if editing a key, just update the edited track, makes refresh less costly + if (key_edit->track < track_edits.size()) { + track_edits[key_edit->track]->update(); + } + return; + } + timeline->update(); timeline->update_values(); if (block_animation_update) { @@ -3944,6 +3964,7 @@ void AnimationTrackEditor::_update_key_edit() { key_edit = memnew(AnimationTrackKeyEdit); key_edit->animation = animation; key_edit->track = selection.front()->key().track; + key_edit->track_editor = this; float ofs = animation->track_get_key_time(key_edit->track, selection.front()->key().key); key_edit->key_ofs = ofs; |