Add option to auto tangent new bezier points in animation editor
This commit is contained in:
parent
02b16d2f54
commit
cef2a8b362
|
@ -503,6 +503,13 @@
|
|||
<member name="editors/animation/onion_layers_past_color" type="Color" setter="" getter="">
|
||||
The modulate color to use for "past" frames displayed in the animation editor's onion skinning feature.
|
||||
</member>
|
||||
<member name="editors/animation/default_bezier_key_behavior" type="int" setter="" getter="">
|
||||
The default behavior for newly created Bezier keys in the animation editor.
|
||||
- [b]Horizontal:[/b] Both tangents are fully horizontal regardless of the key's previous and next values.
|
||||
- [b]Linear:[/b] Key is set to linear with no tangents.
|
||||
- [b]Balanced Automatic:[/b] Both tangents are rotated to match the key's previous and next values. The tangents' length is adjusted according to the distance between the previous and next values. If the key that is being added has no previous or next value, only one of the two tangents will be defined.
|
||||
- [b]Mirrored Automatic:[/b] Both tangents are rotated to match the key's previous and next values. The tangents' length is adjusted according to the distance between the previous and next values, but their length is forced to be equal.
|
||||
</member>
|
||||
<member name="editors/bone_mapper/handle_colors/error" type="Color" setter="" getter="">
|
||||
</member>
|
||||
<member name="editors/bone_mapper/handle_colors/missing" type="Color" setter="" getter="">
|
||||
|
|
|
@ -218,6 +218,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
|
|||
if (EditorSettings::get_singleton()->check_changed_settings_in_group("editors/panning")) {
|
||||
panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
|
||||
}
|
||||
if (EditorSettings::get_singleton()->check_changed_settings_in_group("editors/animation")) {
|
||||
_default_bezier_key_behavior = int(EDITOR_GET("editors/animation/default_bezier_key_behavior"));
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
@ -1238,6 +1241,21 @@ 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 (_default_bezier_key_behavior) {
|
||||
case Animation::HANDLE_MODE_LINEAR: {
|
||||
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), selected_track, k_idx, Animation::HANDLE_MODE_LINEAR, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
case Animation::HANDLE_MODE_BALANCED: {
|
||||
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), selected_track, k_idx, Animation::HANDLE_MODE_BALANCED, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
case Animation::HANDLE_MODE_MIRRORED: {
|
||||
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), selected_track, k_idx, Animation::HANDLE_MODE_MIRRORED, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time);
|
||||
undo_redo->commit_action();
|
||||
|
||||
|
@ -1682,6 +1700,21 @@ 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 (_default_bezier_key_behavior) {
|
||||
case Animation::HANDLE_MODE_LINEAR: {
|
||||
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), selected_track, k_idx, Animation::HANDLE_MODE_LINEAR, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
case Animation::HANDLE_MODE_BALANCED: {
|
||||
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), selected_track, k_idx, Animation::HANDLE_MODE_BALANCED, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
case Animation::HANDLE_MODE_MIRRORED: {
|
||||
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), selected_track, k_idx, Animation::HANDLE_MODE_MIRRORED, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time);
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
|
|
|
@ -193,6 +193,8 @@ class AnimationBezierTrackEdit : public Control {
|
|||
float _bezier_h_to_pixel(float p_h);
|
||||
void _zoom_vertically(real_t p_minimum_value, real_t p_maximum_value);
|
||||
|
||||
int _default_bezier_key_behavior;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _notification(int p_what);
|
||||
|
|
|
@ -4532,6 +4532,23 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
|||
}
|
||||
|
||||
undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, value);
|
||||
if (!created && p_id.type == Animation::TYPE_BEZIER) {
|
||||
int k_idx = animation->track_find_key(p_id.track_idx, time) + 1;
|
||||
switch (int(EDITOR_GET("editors/animation/default_bezier_key_behavior"))) {
|
||||
case Animation::HANDLE_MODE_LINEAR: {
|
||||
undo_redo->add_do_method(this, "_bezier_track_set_key_handle_mode", animation.ptr(), p_id.track_idx, k_idx, Animation::HANDLE_MODE_LINEAR, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
case Animation::HANDLE_MODE_BALANCED: {
|
||||
undo_redo->add_do_method(this, "_bezier_track_set_key_handle_mode", animation.ptr(), p_id.track_idx, k_idx, Animation::HANDLE_MODE_BALANCED, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
case Animation::HANDLE_MODE_MIRRORED: {
|
||||
undo_redo->add_do_method(this, "_bezier_track_set_key_handle_mode", animation.ptr(), p_id.track_idx, k_idx, Animation::HANDLE_MODE_MIRRORED, Animation::HANDLE_SET_MODE_AUTO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (created) {
|
||||
// Just remove the track.
|
||||
|
|
|
@ -867,6 +867,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||
_initial_set("editors/animation/default_create_reset_tracks", true);
|
||||
_initial_set("editors/animation/onion_layers_past_color", Color(1, 0, 0));
|
||||
_initial_set("editors/animation/onion_layers_future_color", Color(0, 1, 0));
|
||||
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/animation/default_bezier_key_behavior", 0, "Horizontal,Linear,Balanced Automatic,Mirrored Automatic");
|
||||
|
||||
// Shader editor
|
||||
_initial_set("editors/shader_editor/behavior/files/restore_shaders_on_load", true);
|
||||
|
|
Loading…
Reference in New Issue