Fix wrong AnimationTrackKeyEdit update timing
This commit is contained in:
parent
7580565c28
commit
5e785e2ea4
2 changed files with 25 additions and 21 deletions
|
@ -3456,7 +3456,7 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re
|
|||
_update_tracks();
|
||||
|
||||
if (animation.is_valid()) {
|
||||
animation->connect("changed", callable_mp(this, &AnimationTrackEditor::_animation_changed), CONNECT_DEFERRED);
|
||||
animation->connect("changed", callable_mp(this, &AnimationTrackEditor::_animation_changed));
|
||||
|
||||
hscroll->show();
|
||||
edit->set_disabled(read_only);
|
||||
|
@ -4657,19 +4657,19 @@ void AnimationTrackEditor::_animation_changed() {
|
|||
}
|
||||
|
||||
if (key_edit) {
|
||||
_update_key_edit();
|
||||
}
|
||||
|
||||
if (key_edit && key_edit->setting) {
|
||||
// If editing a key, just redraw the edited track, makes refresh less costly.
|
||||
if (key_edit->track < track_edits.size()) {
|
||||
if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER) {
|
||||
bezier_edit->queue_redraw();
|
||||
} else {
|
||||
track_edits[key_edit->track]->queue_redraw();
|
||||
if (key_edit->setting) {
|
||||
// If editing a key, just redraw the edited track, makes refresh less costly.
|
||||
if (key_edit->track < track_edits.size()) {
|
||||
if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER) {
|
||||
bezier_edit->queue_redraw();
|
||||
} else {
|
||||
track_edits[key_edit->track]->queue_redraw();
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
_update_key_edit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
animation_changing_awaiting_update = true;
|
||||
|
@ -5289,7 +5289,12 @@ void AnimationTrackEditor::_update_key_edit() {
|
|||
key_edit->track = selection.front()->key().track;
|
||||
key_edit->use_fps = timeline->is_using_fps();
|
||||
|
||||
float ofs = animation->track_get_key_time(key_edit->track, selection.front()->key().key);
|
||||
int key_id = selection.front()->key().key;
|
||||
if (key_id >= animation->track_get_key_count(key_edit->track)) {
|
||||
_clear_key_edit();
|
||||
return; // Probably in the process of rearranging the keys.
|
||||
}
|
||||
float ofs = animation->track_get_key_time(key_edit->track, key_id);
|
||||
key_edit->key_ofs = ofs;
|
||||
key_edit->root_path = root;
|
||||
|
||||
|
@ -5317,6 +5322,11 @@ void AnimationTrackEditor::_update_key_edit() {
|
|||
base_map[track] = NodePath();
|
||||
}
|
||||
|
||||
int key_id = E.key.key;
|
||||
if (key_id >= animation->track_get_key_count(track)) {
|
||||
_clear_key_edit();
|
||||
return; // Probably in the process of rearranging the keys.
|
||||
}
|
||||
key_ofs_map[track].push_back(animation->track_get_key_time(track, E.key.key));
|
||||
}
|
||||
multi_key_edit->key_ofs_map = key_ofs_map;
|
||||
|
@ -5352,6 +5362,7 @@ void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_t
|
|||
ki.pos = p_pos;
|
||||
|
||||
selection.insert(sk, ki);
|
||||
_update_key_edit();
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_move_selection_commit() {
|
||||
|
@ -5428,7 +5439,6 @@ void AnimationTrackEditor::_move_selection_commit() {
|
|||
undo_redo->add_do_method(this, "_redraw_tracks");
|
||||
undo_redo->add_undo_method(this, "_redraw_tracks");
|
||||
undo_redo->commit_action();
|
||||
_update_key_edit();
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_move_selection_cancel() {
|
||||
|
@ -5659,7 +5669,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
|
|||
undo_redo->add_do_method(this, "_redraw_tracks");
|
||||
undo_redo->add_undo_method(this, "_redraw_tracks");
|
||||
undo_redo->commit_action();
|
||||
_update_key_edit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5907,9 +5916,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
}
|
||||
|
||||
float s = scale->get_value();
|
||||
if (s == 0) {
|
||||
ERR_PRINT("Can't scale to 0");
|
||||
}
|
||||
ERR_FAIL_COND_MSG(s == 0, "Can't scale to 0.");
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Anim Scale Keys"));
|
||||
|
@ -5985,8 +5992,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
undo_redo->add_do_method(this, "_redraw_tracks");
|
||||
undo_redo->add_undo_method(this, "_redraw_tracks");
|
||||
undo_redo->commit_action();
|
||||
_update_key_edit();
|
||||
|
||||
} break;
|
||||
|
||||
case EDIT_EASE_SELECTION: {
|
||||
|
|
|
@ -427,7 +427,6 @@ class AnimationTrackEditor : public VBoxContainer {
|
|||
AnimationTrackKeyEdit *key_edit = nullptr;
|
||||
AnimationMultiTrackKeyEdit *multi_key_edit = nullptr;
|
||||
void _update_key_edit();
|
||||
|
||||
void _clear_key_edit();
|
||||
|
||||
Control *box_selection = nullptr;
|
||||
|
|
Loading…
Reference in a new issue