summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Miller <dodgyville@gmail.com>2018-07-14 11:48:40 +1000
committerLuke Miller <dodgyville@gmail.com>2018-07-14 11:48:40 +1000
commit7298a746ce62bc16ffa0d8f248102ff4653c16ab (patch)
tree86c41a70e56092a2deaaae241df0cf2709482c3b
parent1fc7973a00e17025441b6b8333e38d1606c1d304 (diff)
fix issue with bezier tracks using incorrect duration for interpolating values
-rw-r--r--scene/resources/animation.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index e57a2b68c8..8acfdc482a 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -2329,13 +2329,14 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
int iterations = 10;
- float low = 0;
- float high = bt->values[idx + 1].time - bt->values[idx].time;
+ float duration = bt->values[idx + 1].time - bt->values[idx].time; // time duration between our two keyframes
+ float low = 0; // 0% of the current animation segment
+ float high = 1; // 100% of the current animation segment
float middle = 0;
Vector2 start(0, bt->values[idx].value.value);
Vector2 start_out = start + bt->values[idx].value.out_handle;
- Vector2 end(high, bt->values[idx + 1].value.value);
+ Vector2 end(duration, bt->values[idx + 1].value.value);
Vector2 end_in = end + bt->values[idx + 1].value.in_handle;
//narrow high and low as much as possible
@@ -2355,7 +2356,6 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
//interpolate the result:
Vector2 low_pos = _bezier_interp(low, start, start_out, end_in, end);
Vector2 high_pos = _bezier_interp(high, start, start_out, end_in, end);
-
float c = (t - low_pos.x) / (high_pos.x - low_pos.x);
return low_pos.linear_interpolate(high_pos, c).y;