Skip to content

Conversation

@benjitrosch
Copy link
Contributor

@benjitrosch benjitrosch commented Apr 17, 2024

This is a follow up PR on #3919.

During that PR, I went researching for a quaternion cubic spline algorithm that could be used, and landed on SQUAD. Turns out, the GLTF 2.0 very specifically provides an algorithm that is says to use (which looks to me like Cubic Hermite Spline):

Let ak, vk, and bk be the in-tangent, the property value, and the out-tangent of the k-th frame respectively.

The interpolated sampler value vt at the timestamp tc is computed as follows.

vt=(2t3−3t2+1)∗vk+td(t3−2t2+t)∗bk+(−2t3+3t2)∗vk+1+td(t3−t2)∗ak+1

However, Cubic Hermite Spline showed flipping/spinning when I was doing tests due to quaternion double-cover. To alleviate this, I added some logic to check the dot product and negate them (and also normalized them).

After this change I'm happy to say it looks pretty good and should be technically more "correct" and compliant with what GLTF 2.0 expects!

@raysan5 raysan5 merged commit 4491ff0 into raysan5:master Apr 17, 2024
@raysan5
Copy link
Owner

raysan5 commented Apr 17, 2024

@benjitrosch Nice! thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants