summaryrefslogtreecommitdiff
path: root/scene/resources/animation.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-10-20 23:08:02 +0200
committerGitHub <noreply@github.com>2017-10-20 23:08:02 +0200
commit08ebbc90a85ce15e1db2eab3ff3c25d7da1a4246 (patch)
treec523450e9abb785168e8e2d78832acabab32ffbd /scene/resources/animation.cpp
parentf2f75d1f117e52f3f4a033fdf967d35bb3dbaa42 (diff)
parentf4959ee32b2b40521cb622bfb211f1309c820b03 (diff)
Merge pull request #12107 from RandomShaper/fix-anim-before-first-key
Fix animation before first key
Diffstat (limited to 'scene/resources/animation.cpp')
-rw-r--r--scene/resources/animation.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 8dcc8d4e14..21e4a85cd1 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -1171,9 +1171,7 @@ T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, Interpol
ERR_FAIL_COND_V(idx == -2, T());
- if (p_ok)
- *p_ok = true;
-
+ bool result = true;
int next = 0;
float c = 0;
// prepare for all cases of interpolation
@@ -1243,10 +1241,19 @@ T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, Interpol
} else if (idx < 0) {
- idx = next = 0;
+ // only allow extending first key to anim start if looping
+ if (loop)
+ idx = next = 0;
+ else
+ result = false;
}
}
+ if (p_ok)
+ *p_ok = result;
+ if (!result)
+ return T();
+
float tr = p_keys[idx].transition;
if (tr == 0 || idx == next) {
@@ -1298,7 +1305,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3
TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok);
- if (!ok) // ??
+ if (!ok)
return ERR_UNAVAILABLE;
if (r_loc)