diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-20 17:28:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-20 17:28:15 +0200 |
commit | 77ec3ec0a30e38af4cd573b98d3934c18b91a48f (patch) | |
tree | 9df191b98314e9d1b554d44f5fa4f57a861b2adc /editor | |
parent | 34f9a4b76541a35dff93d042404e446f84e3f5b4 (diff) | |
parent | 5c2582ad340cb5b67e8d459a06bf41fd3bb6c386 (diff) |
Merge pull request #32129 from YeldhamDev/fix_track_removal_errors
Fix errors in the animation editor when removing tracks via undo/redo
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_track_editor.cpp | 29 | ||||
-rw-r--r-- | editor/animation_track_editor.h | 2 |
2 files changed, 18 insertions, 13 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 54bb7d3869..263abaeb8f 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -3402,15 +3402,14 @@ void AnimationTrackEditor::_track_remove_request(int p_track) { int idx = p_track; if (idx >= 0 && idx < animation->get_track_count()) { - selection.clear(); - _clear_key_edit(); - //all will be updated after remove anyway, and triggering update here raises error on tracks already removed undo_redo->create_action(TTR("Remove Anim Track")); + undo_redo->add_do_method(this, "_clear_selection", false); undo_redo->add_do_method(animation.ptr(), "remove_track", idx); undo_redo->add_undo_method(animation.ptr(), "add_track", animation->track_get_type(idx), idx); undo_redo->add_undo_method(animation.ptr(), "track_set_path", idx, animation->track_get_path(idx)); - //todo interpolation + + // TODO interpolation. for (int i = 0; i < animation->track_get_key_count(idx); i++) { Variant v = animation->track_get_key_value(idx, i); @@ -3979,10 +3978,10 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE; if (p_id.type == Animation::TYPE_VALUE || p_id.type == Animation::TYPE_BEZIER) { - //wants a new tack + // Wants a new track. { - //hack + // Hack. NodePath np; animation->add_track(p_id.type); animation->track_set_path(animation->get_track_count() - 1, p_id.path); @@ -4036,7 +4035,7 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo Dictionary d; d["location"] = tr.origin; d["scale"] = tr.basis.get_scale(); - d["rotation"] = Quat(tr.basis); //.orthonormalized(); + d["rotation"] = Quat(tr.basis); value = d; } break; case Animation::TYPE_BEZIER: { @@ -4061,7 +4060,8 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo if (created) { - //just remove the track + // Just remove the track. + undo_redo->add_undo_method(this, "_clear_selection", false); undo_redo->add_undo_method(animation.ptr(), "remove_track", p_last_track); p_last_track++; } else { @@ -4665,6 +4665,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, value); + undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); undo_redo->commit_action(); @@ -4872,11 +4873,16 @@ void AnimationTrackEditor::_clear_key_edit() { } } -void AnimationTrackEditor::_clear_selection() { +void AnimationTrackEditor::_clear_selection(bool p_update) { + selection.clear(); - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); + + if (p_update) { + for (int i = 0; i < track_edits.size(); i++) { + track_edits[i]->update(); + } } + _clear_key_edit(); } @@ -5547,7 +5553,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); undo_redo->commit_action(); - //selection.clear(); _update_key_edit(); } } break; diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 4bc41ab188..830d5b52d3 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -387,7 +387,7 @@ class AnimationTrackEditor : public VBoxContainer { void _insert_key_from_track(float p_ofs, int p_track); void _add_method_key(const String &p_method); - void _clear_selection(); + void _clear_selection(bool p_update = false); void _clear_selection_for_anim(const Ref<Animation> &p_anim); void _select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos); |