Skip to content

Instantly share code, notes, and snippets.

@LordNed
Created January 17, 2018 07:33
Show Gist options
  • Save LordNed/f18822b229c9488795af4a249e0c8e82 to your computer and use it in GitHub Desktop.
Save LordNed/f18822b229c9488795af4a249e0c8e82 to your computer and use it in GitHub Desktop.
J3DAnimFix
// ToDo: This fixes the OoB issue when an animation doesn't have a key on the final frame,
// but this isn't totally correct as the time calculation below doesn't take the shifted
// t value into account.
int i = 1;
while (keys[i].Time < t)
{
i++;
if (i >= keys.Count)
{
i = 1;
break;
}
}
float time = (t - keys[i - 1].Time) / (keys[i].Time - keys[i - 1].Time); // Scale to [0, 1]
return CubicInterpolation(keys[i - 1], keys[i], time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment