From e4e8fc63144b704c5f077794a3bb19cab32af302 Mon Sep 17 00:00:00 2001 From: DualMatrix Date: Fri, 9 Nov 2018 12:35:49 +0100 Subject: AnimationPlayer, snap absolute position instead of motion. Fixes #22663 --- editor/animation_track_editor.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 37d26d8e0f..f65825e395 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1253,14 +1253,14 @@ void AnimationTrackEdit::_notification(int p_what) { float offset = animation->track_get_key_time(track, i) - timeline->get_value(); if (editor->is_key_selected(track, i) && editor->is_moving_selection()) { - offset += editor->get_moving_selection_offset(); + offset = editor->snap_time(offset + editor->get_moving_selection_offset()); } offset = offset * scale + limit; if (i < animation->track_get_key_count(track) - 1) { float offset_n = animation->track_get_key_time(track, i + 1) - timeline->get_value(); if (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) { - offset_n += editor->get_moving_selection_offset(); + offset_n = editor->snap_time(offset_n + editor->get_moving_selection_offset()); } offset_n = offset_n * scale + limit; @@ -3187,7 +3187,8 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo case Animation::TYPE_ANIMATION: { value = p_id.value; } break; - default: {} + default: { + } } undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, value); @@ -3876,9 +3877,7 @@ void AnimationTrackEditor::_move_selection_begin() { void AnimationTrackEditor::_move_selection(float p_offset) { moving_selection_offset = p_offset; - if (snap->is_pressed() && step->get_value() != 0) { - moving_selection_offset = Math::stepify(moving_selection_offset, step->get_value()); - } + for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->update(); } @@ -3998,7 +3997,7 @@ void AnimationTrackEditor::_move_selection_commit() { // 2- remove overlapped keys for (Map::Element *E = selection.back(); E; E = E->prev()) { - float newtime = E->get().pos + motion; + float newtime = snap_time(E->get().pos + motion); int idx = animation->track_find_key(E->key().track, newtime, true); if (idx == -1) continue; @@ -4022,7 +4021,7 @@ void AnimationTrackEditor::_move_selection_commit() { // 3-move the keys (re insert them) for (Map::Element *E = selection.back(); E; E = E->prev()) { - float newpos = E->get().pos + motion; + float newpos = snap_time(E->get().pos + motion); /* if (newpos<0) continue; //no add at the beginning @@ -4033,7 +4032,7 @@ void AnimationTrackEditor::_move_selection_commit() { // 4-(undo) remove inserted keys for (Map::Element *E = selection.back(); E; E = E->prev()) { - float newpos = E->get().pos + motion; + float newpos = snap_time(E->get().pos + motion); /* if (newpos<0) continue; //no remove what no inserted @@ -4069,7 +4068,7 @@ void AnimationTrackEditor::_move_selection_commit() { for (Map::Element *E = selection.back(); E; E = E->prev()) { float oldpos = E->get().pos; - float newpos = oldpos + motion; + float newpos = snap_time(oldpos + motion); //if (newpos>=0) undo_redo->add_do_method(this, "_select_at_anim", animation, E->key().track, newpos); undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos); @@ -4346,7 +4345,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { case Animation::TYPE_METHOD: text += " (Methods)"; break; case Animation::TYPE_BEZIER: text += " (Bezier)"; break; case Animation::TYPE_AUDIO: text += " (Audio)"; break; - default: {}; + default: { + }; } TreeItem *it = track_copy_select->create_item(troot); -- cgit v1.2.3