godot
godot copied to clipboard
Make `cubic_interpolate()` consider key time in animation
Fixes #60154.
In the previous implementation, cubic_interpolate() did not consider time, resulting in clunky transitions when the key interval was not constant. The following images show animations with the same keyframes, but the left one is the previous cubic_interpolate() without time(velocity) consideration and the right one is this PR with time(velocity) consideration.

By providing time as an argument, it allows for smoother movements. Also, based on previous implementations, the default values of the argument are -1.0, 0.0, 1.0, 2.0. The result of this argument will be the same as the previous implementation, but if there are performance concerns in Curve or Gradient classes, it may want to separate the functions.
https://user-images.githubusercontent.com/61938263/181659750-d697da3c-d01d-4d86-a2ae-1d3e3d95dddd.mp4
https://user-images.githubusercontent.com/61938263/181659760-8ddc570f-8442-4d4c-917c-1ef4c6a05973.mp4
If anyone don't want overshoot, simply adding more plots will solve the problem, but if the demand is too much, we can consider implementing makima interpolate (#57952) or adding a function to AnimationTrack that switches between the previous implementation and the new one.