summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-06-08 13:42:04 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-06-08 13:42:45 -0300
commit9cb17d7af8c9e49bc7baee2e70144490d6548b1d (patch)
tree83e4db9779ed6a9893732f165f984ba430f04611
parent3aed396a30d4cbcfb4a63c14b8416dad024808b2 (diff)
Avoid animation length from ever being completely, fixes #19420
-rw-r--r--editor/animation_track_editor.cpp4
-rw-r--r--scene/resources/animation.cpp6
2 files changed, 8 insertions, 2 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index adc9821d8a..d8b90bb8db 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -643,6 +643,8 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
if (editing)
return;
+ p_new_len = MAX(0.001, p_new_len);
+
editing = true;
*block_animation_update_ptr = true;
undo_redo->create_action("Change animation length");
@@ -1059,7 +1061,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
time_icon->set_tooltip(TTR("Animation Length Time (seconds)"));
len_hb->add_child(time_icon);
length = memnew(EditorSpinSlider);
- length->set_min(0);
+ length->set_min(0.001);
length->set_max(3600);
length->set_step(0.01);
length->set_allow_greater(true);
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 9c95cba357..fe4d687c23 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -32,6 +32,8 @@
#include "geometry.h"
+#define ANIM_MIN_LENGTH 0.001
+
bool Animation::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
@@ -2524,7 +2526,9 @@ StringName Animation::animation_track_get_key_animation(int p_track, int p_key)
void Animation::set_length(float p_length) {
- ERR_FAIL_COND(length < 0);
+ if (p_length < ANIM_MIN_LENGTH) {
+ p_length = ANIM_MIN_LENGTH;
+ }
length = p_length;
emit_changed();
}