-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cubic_slerp()
may take a rotation path that is not the shortest
#57951
Comments
Edit : Sorry wrong Issue, i was talking about another issue and got confused when i was opened multiple tabs in my browser |
@GNSS-Stylist TokageItLab@5cd3792 There is a problem that the way to interpolate each element of the quaternion directly is spherical-interpolation, not spherical-linear-interpolation. So I tried to adapt it to exponential map, which is probably the most common solution. Can you test it? I think it does make the behavior more consistent. However, cubic-slerp flips the current quaternion when picking the shortest path and it does not match the pre and post sign, which causes strange kickbacks sometimes. I am trying to seek a way to improve it. Another problem is that the exponential map is an approximate expression, so it does not pass unit tests. For normal If I cannot find a way to resolve the kickback, it may look smoother to interpolate each element directly. Then, maybe we should avoid combining |
|
Repost from #58043: For example, if we have [a, -b, c, -d, -e], and the first interpolationA is [a, Q, -b, c], and the next interpolationB is [b, Q, c, -d], then, the sign of the pre value of interpolationB will change (because there is b in interpolationB, but it was -b in interpolationA), and the interpolation-curve will be broken. So, even if we use exp map, cubic_slerp() requires one of the following two things for sign consistency between pre and post.
Linear interpolation in Basis elements has major problems, and linear interpolation in Quaternion elements still has flip problems, so implementation in the track cache may be inevitable. |
We were able to get master...V-Sekai:fix-cubic_slerp to work. There's still some acceleration problems though. 2022-02-14_15.09.39-1.mov2022-02-13_22-02-53.mp42022-02-13_18-11-11.mp4 |
I think the reason is we're ignoring the term in the exp map paper. http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/ |
Updated master...V-Sekai:fix-cubic_slerp if @GNSS-Stylist wants to test. 2022-02-19.21-38-55.mp4 |
Sorry for the late response, I was away from my keyboard for a week. Made a comparison video between the code from @fire 's link (on the left) and my previous component-wise interpolation (on the right, code from #40592 (comment) and previous comments there): QuatInterpComparison.mp4Paths seem to differ somewhat. The same flipping as seen on fire's video can be seen 00:25 onward. There are several glitches when the Z-axis (blue) of the the right-side thingy is close to the world's X-axis, about 1 min onward.
Pondered this for a while... As flipped quaternion represents the same orientation with the non-flipped one, shouldn't this work in any case without a cache or such? I mean does it actually matter which quaternions are flipped as long as they are adjusted to give the shortest path between subsequent ones? My brain refuses to understand the exp map right now, though (if the issue is related to it?). Did some quick tests by flipping (negating all components) of a some quaternions in animation and this didn't change anything, apart from some minor rounding errors causing the center box to turn green/red instead of solid green by changing z-order just enough. |
Quaternions that are flipped in sign show the same orientation, but interpolation make difference the values of those quaternions.
The only successful way I have done in my experiments so far is to do an flip of all the key values in advance of the animation, but not during the interpolation. This ensures that the sign does not change during the interpolation process, so no odd paths are created. I'm discussing with @fire how to implement this. For example, we could do an implicit flip every time we insert/change a Quaternion key. |
@TokageItLab I noticed your animation scene has something wrong. When I duplicated the track and set the path to be cubic_slerp_test_duplicate_track.zip Also, scaling the track by 4 made the results easier to analyse. |
This comment was marked as outdated.
This comment was marked as outdated.
Before: broken_cubic_slerp.mp4After #63380: fixed_cubic_slerp.mp4 |
Godot version
4.0.dev, 3.4
System information
Any
Issue description
#40592 split and resend. There is a problem with the implementation of
cubic_slerp()
, it may mix non-shortest paths in the calculation.Steps to reproduce
broken_cubic_slerp.mp4
Minimal reproduction project
cubic_slerp_test.zip
The text was updated successfully, but these errors were encountered: