Skip to content

Fix wrong interpolation ratio in glTF TrackData.populateTransform()#2897

Open
DieterDePaepe wants to merge 1 commit into
jMonkeyEngine:masterfrom
DieterDePaepe:fix-gltf-trackdata-interpolation-ratio
Open

Fix wrong interpolation ratio in glTF TrackData.populateTransform()#2897
DieterDePaepe wants to merge 1 commit into
jMonkeyEngine:masterfrom
DieterDePaepe:fix-gltf-trackdata-interpolation-ratio

Conversation

@DieterDePaepe

Copy link
Copy Markdown

When a node's translation/rotation/scale channels carry different keyframe timestamps, update() merges them onto one shared time grid and gap-fills missing samples via populateTransform()/interpolate(). The blend ratio for that interpolation was computed as
"currentKeyFrame.time / (nextKeyFrame.time - lastKeyFrame.time)", missing "- lastKeyFrame.time" in the numerator. Instead of the intended 0..1 blend position within [lastKeyFrame.time, nextKeyFrame.time], this passed the clip's absolute elapsed time into Quaternion.nlerp(), which doesn't clamp its blend parameter and so extrapolated wildly rather than interpolating.

Only triggers on the "channels don't share identical keyframe times" merge
path (equalTimes(timeArrays) false) — simple clips where every channel is
sampled at the same rate never hit it.

Verified against a real affected clip: a bone was rotating >100° from bind
mid-clip in a stretch where the source data is smooth; after the fix,
motion is normal throughout.

Forum discussion: https://hub.jmonkeyengine.org/t/wrong-interpolation-in-gltf-loader/49640

(Created with help from AI)

When a node's translation/rotation/scale channels carry different keyframe
timestamps, update() merges them onto one shared time grid and gap-fills
missing samples via populateTransform()/interpolate(). The blend ratio for
that interpolation was computed as
"currentKeyFrame.time / (nextKeyFrame.time - lastKeyFrame.time)", missing
"- lastKeyFrame.time" in the numerator. Instead of the intended 0..1 blend
position within [lastKeyFrame.time, nextKeyFrame.time], this passed the
clip's absolute elapsed time into Quaternion.nlerp(), which doesn't clamp
its blend parameter and so extrapolated wildly rather than interpolating.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request corrects the interpolation ratio calculation in TrackData.java by subtracting the last keyframe's time from the current keyframe's time, ensuring proper interpolation between keyframes. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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.

1 participant