Fix seeking bug in AnimationPlayerEditor
This commit is contained in:
parent
80de898d72
commit
21833f3dfd
|
@ -1672,7 +1672,7 @@ void AnimationBezierTrackEdit::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("_update_locked_tracks_after"), &AnimationBezierTrackEdit::_update_locked_tracks_after);
|
||||
ClassDB::bind_method(D_METHOD("_bezier_track_insert_key"), &AnimationBezierTrackEdit::_bezier_track_insert_key);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag")));
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position")));
|
||||
ADD_SIGNAL(MethodInfo("remove_request", PropertyInfo(Variant::INT, "track")));
|
||||
ADD_SIGNAL(MethodInfo("insert_key", PropertyInfo(Variant::FLOAT, "offset")));
|
||||
ADD_SIGNAL(MethodInfo("select_key", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "single"), PropertyInfo(Variant::INT, "track")));
|
||||
|
|
|
@ -1683,7 +1683,7 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
int x = mb->get_position().x - get_name_limit();
|
||||
|
||||
float ofs = x / get_zoom_scale() + get_value();
|
||||
emit_signal(SNAME("timeline_changed"), ofs, false, mb->is_alt_pressed());
|
||||
emit_signal(SNAME("timeline_changed"), ofs, mb->is_alt_pressed());
|
||||
dragging_timeline = true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,7 +1705,7 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
if (dragging_timeline) {
|
||||
int x = mm->get_position().x - get_name_limit();
|
||||
float ofs = x / get_zoom_scale() + get_value();
|
||||
emit_signal(SNAME("timeline_changed"), ofs, false, mm->is_alt_pressed());
|
||||
emit_signal(SNAME("timeline_changed"), ofs, mm->is_alt_pressed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1748,7 +1748,7 @@ void AnimationTimelineEdit::_track_added(int p_track) {
|
|||
void AnimationTimelineEdit::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("zoom_changed"));
|
||||
ADD_SIGNAL(MethodInfo("name_limit_changed"));
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag"), PropertyInfo(Variant::BOOL, "timeline_only")));
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "timeline_only")));
|
||||
ADD_SIGNAL(MethodInfo("track_added", PropertyInfo(Variant::INT, "track")));
|
||||
ADD_SIGNAL(MethodInfo("length_changed", PropertyInfo(Variant::FLOAT, "size")));
|
||||
|
||||
|
@ -3148,7 +3148,7 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect
|
|||
}
|
||||
|
||||
void AnimationTrackEdit::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag"), PropertyInfo(Variant::BOOL, "timeline_only")));
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "timeline_only")));
|
||||
ADD_SIGNAL(MethodInfo("remove_request", PropertyInfo(Variant::INT, "track")));
|
||||
ADD_SIGNAL(MethodInfo("dropped", PropertyInfo(Variant::INT, "from_track"), PropertyInfo(Variant::INT, "to_track")));
|
||||
ADD_SIGNAL(MethodInfo("insert_key", PropertyInfo(Variant::FLOAT, "offset")));
|
||||
|
@ -3468,8 +3468,8 @@ void AnimationTrackEditor::_name_limit_changed() {
|
|||
_redraw_tracks();
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only) {
|
||||
emit_signal(SNAME("timeline_changed"), p_new_pos, p_drag, p_timeline_only);
|
||||
void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_timeline_only) {
|
||||
emit_signal(SNAME("timeline_changed"), p_new_pos, p_timeline_only);
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_track_remove_request(int p_track) {
|
||||
|
@ -5575,7 +5575,7 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) {
|
|||
pos = 0;
|
||||
}
|
||||
set_anim_pos(pos);
|
||||
emit_signal(SNAME("timeline_changed"), pos, true, false);
|
||||
emit_signal(SNAME("timeline_changed"), pos, false);
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeline_only) {
|
||||
|
@ -5602,7 +5602,7 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli
|
|||
}
|
||||
set_anim_pos(pos);
|
||||
|
||||
emit_signal(SNAME("timeline_changed"), pos, true, p_timeline_only);
|
||||
emit_signal(SNAME("timeline_changed"), pos, p_timeline_only);
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
||||
|
@ -6374,7 +6374,7 @@ void AnimationTrackEditor::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("_bezier_track_set_key_handle_mode", "animation", "track_idx", "key_idx", "key_handle_mode", "key_handle_set_mode"), &AnimationTrackEditor::_bezier_track_set_key_handle_mode, DEFVAL(Animation::HANDLE_SET_MODE_NONE));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag"), PropertyInfo(Variant::BOOL, "timeline_only")));
|
||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "timeline_only")));
|
||||
ADD_SIGNAL(MethodInfo("keying_changed"));
|
||||
ADD_SIGNAL(MethodInfo("animation_len_changed", PropertyInfo(Variant::FLOAT, "len")));
|
||||
ADD_SIGNAL(MethodInfo("animation_step_changed", PropertyInfo(Variant::FLOAT, "step")));
|
||||
|
|
|
@ -409,7 +409,7 @@ class AnimationTrackEditor : public VBoxContainer {
|
|||
void _check_bezier_exist();
|
||||
|
||||
void _name_limit_changed();
|
||||
void _timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only);
|
||||
void _timeline_changed(float p_new_pos, bool p_timeline_only);
|
||||
void _track_remove_request(int p_track);
|
||||
void _animation_track_remove_request(int p_track, Ref<Animation> p_from_animation);
|
||||
void _track_grab_focus(int p_track);
|
||||
|
|
|
@ -335,7 +335,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
|
|||
}
|
||||
|
||||
AnimationPlayerEditor::get_singleton()->get_track_editor()->update_keying();
|
||||
_animation_key_editor_seek(timeline_position, false);
|
||||
_animation_key_editor_seek(timeline_position);
|
||||
|
||||
emit_signal("animation_selected", current);
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ Ref<Animation> AnimationPlayerEditor::_animation_clone(Ref<Animation> p_anim) {
|
|||
return new_anim;
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool p_timeline_only) {
|
||||
void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_timeline_only) {
|
||||
if (updating || !player || player->is_playing()) {
|
||||
return;
|
||||
};
|
||||
|
@ -1247,22 +1247,14 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool
|
|||
Ref<Animation> anim;
|
||||
anim = player->get_animation(current);
|
||||
|
||||
float pos = CLAMP((double)anim->get_length() * (p_value / frame->get_max()), 0, (double)anim->get_length());
|
||||
double pos = CLAMP((double)anim->get_length() * (p_value / frame->get_max()), 0, (double)anim->get_length());
|
||||
if (track_editor->is_snap_enabled()) {
|
||||
pos = Math::snapped(pos, _get_editor_step());
|
||||
}
|
||||
pos = CLAMP(pos, 0, (double)anim->get_length() - CMP_EPSILON2); // Hack: Avoid fposmod with LOOP_LINEAR.
|
||||
|
||||
if (!p_timeline_only) {
|
||||
if (player->is_valid() && !p_set) {
|
||||
double delta = player->get_current_animation_position();
|
||||
player->seek(pos, true, true);
|
||||
player->seek(pos + delta, true, true);
|
||||
} else {
|
||||
if (player->is_playing()) {
|
||||
player->stop();
|
||||
}
|
||||
player->seek(pos, true, true);
|
||||
}
|
||||
if (!p_timeline_only && anim.is_valid()) {
|
||||
player->seek(pos, true, true);
|
||||
}
|
||||
|
||||
track_editor->set_anim_pos(pos);
|
||||
|
@ -1313,7 +1305,7 @@ void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len)
|
|||
frame->set_max(p_len);
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag, bool p_timeline_only) {
|
||||
void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_timeline_only) {
|
||||
timeline_position = p_pos;
|
||||
|
||||
if (!is_visible_in_tree()) {
|
||||
|
@ -1335,7 +1327,7 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag,
|
|||
updating = true;
|
||||
frame->set_value(Math::snapped(p_pos, _get_editor_step()));
|
||||
updating = false;
|
||||
_seek_value_changed(p_pos, !p_drag, p_timeline_only);
|
||||
_seek_value_changed(p_pos, p_timeline_only);
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
|
@ -2006,7 +1998,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
|
|||
|
||||
animation->connect(SNAME("item_selected"), callable_mp(this, &AnimationPlayerEditor::_animation_selected));
|
||||
|
||||
frame->connect(SNAME("value_changed"), callable_mp(this, &AnimationPlayerEditor::_seek_value_changed).bind(true, false));
|
||||
frame->connect(SNAME("value_changed"), callable_mp(this, &AnimationPlayerEditor::_seek_value_changed).bind(false));
|
||||
scale->connect(SNAME("text_submitted"), callable_mp(this, &AnimationPlayerEditor::_scale_changed));
|
||||
|
||||
add_child(track_editor);
|
||||
|
|
|
@ -196,7 +196,7 @@ class AnimationPlayerEditor : public VBoxContainer {
|
|||
Ref<Animation> _animation_clone(const Ref<Animation> p_anim);
|
||||
void _animation_resource_edit();
|
||||
void _scale_changed(const String &p_scale);
|
||||
void _seek_value_changed(float p_value, bool p_set = false, bool p_timeline_only = false);
|
||||
void _seek_value_changed(float p_value, bool p_timeline_only = false);
|
||||
void _blend_editor_next_changed(const int p_idx);
|
||||
|
||||
void _edit_animation_blend();
|
||||
|
@ -213,7 +213,7 @@ class AnimationPlayerEditor : public VBoxContainer {
|
|||
void _animation_player_changed(Object *p_pl);
|
||||
void _animation_libraries_updated();
|
||||
|
||||
void _animation_key_editor_seek(float p_pos, bool p_drag, bool p_timeline_only = false);
|
||||
void _animation_key_editor_seek(float p_pos, bool p_timeline_only = false);
|
||||
void _animation_key_editor_anim_len_changed(float p_len);
|
||||
|
||||
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
|
||||
|
|
Loading…
Reference in New Issue