diff options
author | Juan Linietsky <juan@godotengine.org> | 2019-03-03 17:53:59 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2019-03-03 17:57:16 -0300 |
commit | 8b4c4d9b2fbfa39e71bc1e4f4fcdd5377a9396e4 (patch) | |
tree | 7006dd0c89288c09d7b6b2faae393404406a6e64 /editor | |
parent | ae886a6f32b3cacc342ab3c4b52fa5e09d91fa49 (diff) |
Implement a more coherent (and way less hack) way to block animation updates, fixes #24618
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_track_editor.cpp | 30 | ||||
-rw-r--r-- | editor/animation_track_editor.h | 9 | ||||
-rw-r--r-- | editor/animation_track_editor_plugins.cpp | 6 |
3 files changed, 1 insertions, 44 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 6b45ca2cae..6b863a162c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -692,12 +692,10 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { p_new_len = MAX(0.001, p_new_len); editing = true; - *block_animation_update_ptr = true; undo_redo->create_action(TTR("Change Animation Length")); undo_redo->add_do_method(animation.ptr(), "set_length", p_new_len); undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length()); undo_redo->commit_action(); - *block_animation_update_ptr = false; editing = false; update(); @@ -706,12 +704,10 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { void AnimationTimelineEdit::_anim_loop_pressed() { - *block_animation_update_ptr = true; undo_redo->create_action(TTR("Change Animation Loop")); undo_redo->add_do_method(animation.ptr(), "set_loop", loop->is_pressed()); undo_redo->add_undo_method(animation.ptr(), "set_loop", animation->has_loop()); undo_redo->commit_action(); - *block_animation_update_ptr = false; } int AnimationTimelineEdit::get_buttons_width() const { @@ -936,10 +932,6 @@ Size2 AnimationTimelineEdit::get_minimum_size() const { return ms; } -void AnimationTimelineEdit::set_block_animation_update_ptr(bool *p_block_ptr) { - block_animation_update_ptr = p_block_ptr; -} - void AnimationTimelineEdit::set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } @@ -1080,7 +1072,6 @@ void AnimationTimelineEdit::_bind_methods() { AnimationTimelineEdit::AnimationTimelineEdit() { - block_animation_update_ptr = NULL; editing = false; name_limit = 150; zoom = NULL; @@ -1884,12 +1875,10 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { Point2 pos = mb->get_position(); if (check_rect.has_point(pos)) { - *block_animation_update_ptr = true; undo_redo->create_action(TTR("Toggle Track Enabled")); undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); undo_redo->commit_action(); - *block_animation_update_ptr = false; update(); accept_event(); } @@ -2186,12 +2175,10 @@ void AnimationTrackEdit::_menu_selected(int p_index) { case MENU_CALL_MODE_CAPTURE: { Animation::UpdateMode update_mode = Animation::UpdateMode(p_index); - *block_animation_update_ptr = true; 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)); undo_redo->commit_action(); - *block_animation_update_ptr = false; update(); } break; @@ -2200,24 +2187,20 @@ void AnimationTrackEdit::_menu_selected(int p_index) { case MENU_INTERPOLATION_CUBIC: { Animation::InterpolationType interp_mode = Animation::InterpolationType(p_index - MENU_INTERPOLATION_NEAREST); - *block_animation_update_ptr = true; 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)); undo_redo->commit_action(); - *block_animation_update_ptr = false; update(); } break; case MENU_LOOP_WRAP: case MENU_LOOP_CLAMP: { bool loop_wrap = p_index == MENU_LOOP_WRAP; - *block_animation_update_ptr = true; 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)); undo_redo->commit_action(); - *block_animation_update_ptr = false; update(); } break; @@ -2235,10 +2218,6 @@ void AnimationTrackEdit::_menu_selected(int p_index) { } } -void AnimationTrackEdit::set_block_animation_update_ptr(bool *p_block_ptr) { - block_animation_update_ptr = p_block_ptr; -} - void AnimationTrackEdit::cancel_drop() { if (dropping_at != 0) { dropping_at = 0; @@ -2301,7 +2280,6 @@ AnimationTrackEdit::AnimationTrackEdit() { root = NULL; path = NULL; menu = NULL; - block_animation_update_ptr = NULL; clicking_on_name = false; dropping_at = 0; @@ -3384,7 +3362,6 @@ void AnimationTrackEditor::_update_tracks() { track_edit->set_undo_redo(undo_redo); track_edit->set_timeline(timeline); - track_edit->set_block_animation_update_ptr(&block_animation_update); track_edit->set_root(root); track_edit->set_animation_and_track(animation, i); track_edit->set_play_position(timeline->get_play_position()); @@ -3425,7 +3402,7 @@ void AnimationTrackEditor::_animation_changed() { timeline->update(); timeline->update_values(); - if (block_animation_update) { + if (undo_redo->is_commiting_action()) { for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->update(); } @@ -4075,9 +4052,7 @@ void AnimationTrackEditor::_move_selection_commit() { undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos); } - block_animation_update = true; //animation will change and this is triggered from a signal, so block updates undo_redo->commit_action(); - block_animation_update = false; moving_selection = false; for (int i = 0; i < track_edits.size(); i++) { @@ -4778,7 +4753,6 @@ void AnimationTrackEditor::_bind_methods() { AnimationTrackEditor::AnimationTrackEditor() { root = NULL; - block_animation_update = false; undo_redo = EditorNode::get_singleton()->get_undo_redo(); @@ -4796,7 +4770,6 @@ AnimationTrackEditor::AnimationTrackEditor() { timeline_vbox->add_constant_override("separation", 0); timeline = memnew(AnimationTimelineEdit); - timeline->set_block_animation_update_ptr(&block_animation_update); timeline->set_undo_redo(undo_redo); timeline_vbox->add_child(timeline); timeline->connect("timeline_changed", this, "_timeline_changed"); @@ -4815,7 +4788,6 @@ AnimationTrackEditor::AnimationTrackEditor() { bezier_edit = memnew(AnimationBezierTrackEdit); timeline_vbox->add_child(bezier_edit); - bezier_edit->set_block_animation_update_ptr(&block_animation_update); bezier_edit->set_undo_redo(undo_redo); bezier_edit->set_editor(this); bezier_edit->set_timeline(timeline); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 47058839ba..4ad8b6fd68 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -76,7 +76,6 @@ class AnimationTimelineEdit : public Range { Rect2 hsize_rect; bool editing; - bool *block_animation_update_ptr; //used to block all tracks re-gen (speed up) bool panning_timeline; float panning_timeline_from; @@ -104,7 +103,6 @@ public: void set_zoom(Range *p_zoom); Range *get_zoom() const { return zoom; } void set_undo_redo(UndoRedo *p_undo_redo); - void set_block_animation_update_ptr(bool *p_block_ptr); void set_play_position(float p_pos); float get_play_position() const; @@ -170,8 +168,6 @@ class AnimationTrackEdit : public Control { void _menu_selected(int p_index); - bool *block_animation_update_ptr; //used to block all tracks re-gen (speed up) - void _path_entered(const String &p_text); void _play_position_draw(); mutable int dropping_at; @@ -216,7 +212,6 @@ public: AnimationTimelineEdit *get_timeline() const { return timeline; } AnimationTrackEditor *get_editor() const { return editor; } UndoRedo *get_undo_redo() const { return undo_redo; } - bool *get_block_animation_update_ptr() { return block_animation_update_ptr; } void set_animation_and_track(const Ref<Animation> &p_animation, int p_track); virtual Size2 get_minimum_size() const; @@ -226,8 +221,6 @@ public: void set_editor(AnimationTrackEditor *p_editor); void set_root(Node *p_root); - void set_block_animation_update_ptr(bool *p_block_ptr); - void set_play_position(float p_pos); void update_play_position(); void cancel_drop(); @@ -313,8 +306,6 @@ class AnimationTrackEditor : public VBoxContainer { Vector<AnimationTrackEdit *> track_edits; Vector<AnimationTrackEditGroup *> groups; - bool block_animation_update; - int _get_track_selected(); void _animation_changed(); void _update_tracks(); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 399d561e28..baf417fed7 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -1004,12 +1004,10 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant ofs += 0.001; } - *get_block_animation_update_ptr() = true; get_undo_redo()->create_action(TTR("Add Audio Track Clip")); get_undo_redo()->add_do_method(get_animation().ptr(), "audio_track_insert_key", get_track(), ofs, stream); get_undo_redo()->add_undo_method(get_animation().ptr(), "track_remove_key_at_position", get_track(), ofs); get_undo_redo()->commit_action(); - *get_block_animation_update_ptr() = false; update(); return; @@ -1098,21 +1096,17 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) { float ofs_local = -len_resizing_rel / get_timeline()->get_zoom_scale(); if (len_resizing_start) { float prev_ofs = get_animation()->audio_track_get_key_start_offset(get_track(), len_resizing_index); - *get_block_animation_update_ptr() = true; get_undo_redo()->create_action(TTR("Change Audio Track Clip Start Offset")); get_undo_redo()->add_do_method(get_animation().ptr(), "audio_track_set_key_start_offset", get_track(), len_resizing_index, prev_ofs + ofs_local); get_undo_redo()->add_undo_method(get_animation().ptr(), "audio_track_set_key_start_offset", get_track(), len_resizing_index, prev_ofs); get_undo_redo()->commit_action(); - *get_block_animation_update_ptr() = false; } else { float prev_ofs = get_animation()->audio_track_get_key_end_offset(get_track(), len_resizing_index); - *get_block_animation_update_ptr() = true; get_undo_redo()->create_action(TTR("Change Audio Track Clip End Offset")); get_undo_redo()->add_do_method(get_animation().ptr(), "audio_track_set_key_end_offset", get_track(), len_resizing_index, prev_ofs + ofs_local); get_undo_redo()->add_undo_method(get_animation().ptr(), "audio_track_set_key_end_offset", get_track(), len_resizing_index, prev_ofs); get_undo_redo()->commit_action(); - *get_block_animation_update_ptr() = false; } len_resizing = false; |