summaryrefslogtreecommitdiffstats
path: root/editor/animation_bezier_editor.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-04 17:12:22 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-04 17:12:22 +0200
commit4d984b63697d840f2c823608d2c46740fb44651a (patch)
treef2f0147594b9697a0fee0f6dcb1cae4715d546df /editor/animation_bezier_editor.cpp
parent0452cbee7512daefe1a01ab63f339397af751c34 (diff)
parent7c6f32ddbff4186bc91db68aad7460b2d932924d (diff)
downloadredot-engine-4d984b63697d840f2c823608d2c46740fb44651a.tar.gz
Merge pull request #93930 from Arnklit/short-animation-length-bezier-handle-fix
Clamp bezier handle length to half the length of animation
Diffstat (limited to 'editor/animation_bezier_editor.cpp')
-rw-r--r--editor/animation_bezier_editor.cpp19
1 files changed, 3 insertions, 16 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index ad7598202f..aa8962b580 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -1220,7 +1220,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
//insert new point
if (mb->get_position().x >= limit && mb->get_position().x < get_size().width && mb->is_command_or_control_pressed()) {
float h = (get_size().height / 2.0 - mb->get_position().y) * timeline_v_zoom + timeline_v_scroll;
- Array new_point = make_default_bezier_key(h);
+ Array new_point = animation->make_default_bezier_key(h);
real_t time = ((mb->get_position().x - limit) / timeline->get_zoom_scale()) + timeline->get_value();
while (animation->track_find_key(selected_track, time, Animation::FIND_MODE_APPROX) != -1) {
@@ -1643,19 +1643,6 @@ void AnimationBezierTrackEdit::_zoom_callback(float p_zoom_factor, Vector2 p_ori
queue_redraw();
}
-Array AnimationBezierTrackEdit::make_default_bezier_key(float p_value) {
- Array new_point;
- new_point.resize(5);
-
- new_point[0] = p_value;
- new_point[1] = -0.25;
- new_point[2] = 0;
- new_point[3] = 0.25;
- new_point[4] = 0;
-
- return new_point;
-}
-
float AnimationBezierTrackEdit::get_bezier_key_value(Array p_bezier_key_array) {
return p_bezier_key_array[0];
}
@@ -1675,7 +1662,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) {
time += 0.001;
}
float h = (get_size().height / 2.0 - menu_insert_key.y) * timeline_v_zoom + timeline_v_scroll;
- Array new_point = make_default_bezier_key(h);
+ Array new_point = animation->make_default_bezier_key(h);
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Add Bezier Point"));
undo_redo->add_do_method(animation.ptr(), "track_insert_key", selected_track, time, new_point);
@@ -1877,7 +1864,7 @@ void AnimationBezierTrackEdit::paste_keys(real_t p_ofs, bool p_ofs_valid) {
Variant value = key.value;
if (key.track_type != Animation::TYPE_BEZIER) {
- value = make_default_bezier_key(key.value);
+ value = animation->make_default_bezier_key(key.value);
}
undo_redo->add_do_method(animation.ptr(), "track_insert_key", selected_track, dst_time, value, key.transition);