-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Use Hermite instead of Bezier for glTF spline interpolation #93597
Use Hermite instead of Bezier for glTF spline interpolation #93597
Conversation
We’ll look into this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it is fixed in SceneFormatImporterGLTFInterpolate T bezier()
instead it?
Yes, it is the other option. I went for the minimal change in the code, but changing the |
This comment was marked as resolved.
This comment was marked as resolved.
ba61f00
to
640dfac
Compare
Is the test case in #93596 ok to validate this or is there other cases? |
It does test the spline interpolation for translation and scaling (rotation works differently) for arbitrary values and tangents. Personally, I would be confident to use it as it is. |
I will try to do a review in a few days and then approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that rename the method to hermite()
.
However, in fact, these calculations are already defined in Godot's Math function which is completely the same, so all you need to do is to call it.
catmull_rom()
is same withMath::cubic_interpolate()
hermite()
is same withMath::smoothstep()
For now, if you change the code to call the Math function in those method, it should be approve-able.
BTW, to be consistent with the Math function, it would be also okay to revert the renaming of harmite()
to smoothstep()
, and rename catmull_rom()
to cubic()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, smoothstep()
does not allow to set start and end tangents individually, so you probably need to define a function called hermite_interpolate()
in Math class. Well, since that is an additional feature, we can follow up later. I think this PR is fine, although catmull_rom()
could be renamed to cubic()
(but might be odd since glTF definition calls the hermite spline as cubic...).
There are so many different types of cubic splines, I would say it's probably better to keep their names explicit when possible. |
Looks good! Could you squash the commits? See PR workflow for instructions. |
640dfac
to
e7f34aa
Compare
Thanks! And congrats for your first merged Godot contribution 🎉 |
Thanks to the Godot team for making the whole process feel great! |
@Gurvan If you have time, give it a try the PR to implement |
The cubic spline interpolation implementation in glTF animations wrongly uses Bezier splines instead of Hermite splines (gltf 2.0 spec, Hermite Spline).
This results in incorrect interpolation, see related issue.
Thankfully, there is an easy conversion from Hermite coefficients to Bezier coefficients that fixes the issue with minimal change.