-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to auto tangent new bezier points in animation editor #95564
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fix docs line. You can use the command godot.exe --doctool
to make document template.
editor/animation_bezier_editor.cpp
Outdated
@@ -1231,6 +1231,17 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { | |||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); | |||
undo_redo->create_action(TTR("Add Bezier Point")); | |||
undo_redo->add_do_method(animation.ptr(), "bezier_track_insert_key", selected_track, time, new_point[0], Vector2(new_point[1], new_point[2]), Vector2(new_point[3], new_point[4])); | |||
int k_idx = animation->track_find_key(selected_track, time) + 1; | |||
switch (int(EDITOR_GET("editors/animation/default_bezier_key_behavior"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retrieved value of the EDITOR_GET
must be cached in AnimationBezierTrackEdit::_notification()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. maybe you can check if I did it the right way.
editor/animation_bezier_editor.cpp
Outdated
@@ -1670,6 +1681,17 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) { | |||
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); | |||
int k_idx = animation->track_find_key(selected_track, time) + 1; | |||
switch (int(EDITOR_GET("editors/animation/default_bezier_key_behavior"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. maybe you can check if I did it the right way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally (rebased on top of master
906a4e9), it mostly works as expected.
However, if you hold Ctrl and drag the mouse to create a new point, the tangents won't update automatically after the initial click (i.e. during the drag motion):
bezier_balanced.mp4
bezier_mirorred.mp4
This should probably be changed to perform tangent changes continuously during the initial dragging motion (but not after, unless we add new settings to use Auto Tangent as a default). Also, double-check that undo-redo works correctly in this case: pressing Ctrl + Z should undo the key addition, whereas it currently only works correctly if you haven't performed any dragging at all.
36ecad4
to
cef2a8b
Compare
Rebased and tried to apply @TokageItLab and @Calinou 's comments. Still have to work on making sure that it works when you drag the keys as Calinou pointed out it in his last comment. Marking as draft until I solve that. |
@Calinou outside this PR should the current behavior of adding and dragging a key with Ctrl be changed so it's registered as a single do action that can be undone with a single undo? That part of the behavior isn't from this PR. Current Do/Undo history when Ctrl + Click dragging a point into the bezier editor and undoing it. |
I'd say yes, I expect those to be considered a single action. |
08c5220
to
45ee246
Compare
45ee246
to
4fb23e3
Compare
It now works correctly to ctrl+click+drag insert keys (they re-balance after release if needed and it works to drag them into another order as well). Big thanks to @mihe for helping out with this. godot.windows.editor.dev.x86_64_H3qq6WP20P.mp4I still want to add making the key handles update while dragging in the draw function when you are in the auto modes. |
This adds an option to set the default behavior of new bezier keys in the editor settings
This would close godotengine/godot-proposals#10250
Example of behavior when the behavior is set to Mirrored Automatic
godot.windows.editor.dev.x86_64_qrJA6lPQOc.mp4