Skip to content

Commit

Permalink
Add editor setting for default animation step
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Dec 28, 2024
1 parent 99a8ab7 commit 95f2cf1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@
If [code]true[/code], display a confirmation dialog when adding a new track to an animation by pressing the "key" icon next to a property. Holding Shift will bypass the dialog.
If [code]false[/code], the behavior is reversed, i.e. the dialog only appears when Shift is held.
</member>
<member name="editors/animation/default_animation_step" type="float" setter="" getter="">
Default step used when creating a new [Animation] in the Animation bottom panel. Only affects the first animation created in the [AnimationPlayer]. By default, other newly created animations will use the step from the previous ones.
</member>
<member name="editors/animation/default_create_bezier_tracks" type="bool" setter="" getter="">
If [code]true[/code], create a Bezier track instead of a standard track when pressing the "key" icon next to a property. Bezier tracks provide more control over animation curves, but are more difficult to adjust quickly.
</member>
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/window.h"
#include "scene/resources/animation.h"

// PRIVATE METHODS

Expand Down Expand Up @@ -895,6 +896,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/polygon_editor/auto_bake_delay", 1.5, "-1.0,10.0,0.01");

// Animation
_initial_set("editors/animation/default_animation_step", Animation::DEFAULT_STEP);
_initial_set("editors/animation/autorename_animation_tracks", true);
_initial_set("editors/animation/confirm_insert_track", true, true);
_initial_set("editors/animation/default_create_bezier_tracks", false, true);
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/animation_player_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ void AnimationPlayerEditor::_animation_name_edited() {
if (current_anim.is_valid()) {
new_anim->set_step(current_anim->get_step());
}
} else {
new_anim->set_step(EDITOR_GET("editors/animation/default_animation_step"));
}

String library_name;
Expand Down
3 changes: 2 additions & 1 deletion scene/resources/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Animation : public Resource {
typedef uint32_t TypeHash;

static inline String PARAMETERS_BASE_PATH = "parameters/";
static inline constexpr real_t DEFAULT_STEP = 1.0 / 30;

enum TrackType : uint8_t {
TYPE_VALUE, // Set a value in a property, can be interpolated.
Expand Down Expand Up @@ -284,7 +285,7 @@ class Animation : public Resource {
_FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const;

double length = 1.0;
real_t step = 1.0 / 30;
real_t step = DEFAULT_STEP;
LoopMode loop_mode = LOOP_NONE;
bool capture_included = false;
void _check_capture_included();
Expand Down

0 comments on commit 95f2cf1

Please sign in to comment.