summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-07-17 14:43:47 +0200
committerGitHub <noreply@github.com>2018-07-17 14:43:47 +0200
commitf71ffa97248e29f1dd8ee5507d4430b08b456842 (patch)
treecc4d5817e3f5ef84baf47519229cfb7849251eba
parent044737246b81a09bf97070b9a719b4d0aa303535 (diff)
parent7298a746ce62bc16ffa0d8f248102ff4653c16ab (diff)
Merge pull request #20146 from dodgyville/bezier_fixes_19777
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;