Fix segfault for glTF animations not keyframed at 0
When loading glTF animations we lerp between keyframes, and previously assume that if the frame we are considering has a later keyframe, there must be a previous keyframe. This is not true if the animation's first keyframe is some time into the animation. In this case we now effectively clamp to that first keyframe for any time prior to it.
This commit is contained in:
parent
6c67ef3da0
commit
6322facb53
|
|
@ -4120,11 +4120,11 @@ static ModelAnimation* LoadGLTFModelAnimations(const char *fileName, int *animCo
|
|||
if (frameTime < inputFrameTime)
|
||||
{
|
||||
shouldSkipFurtherTransformation = false;
|
||||
outputMin = j - 1;
|
||||
outputMin = (j == 0) ? 0 : j - 1;
|
||||
outputMax = j;
|
||||
|
||||
float previousInputTime = 0.0f;
|
||||
if (GltfReadFloat(sampler->input, j - 1, (float*)&previousInputTime, 1))
|
||||
if (GltfReadFloat(sampler->input, outputMin, (float*)&previousInputTime, 1))
|
||||
{
|
||||
lerpPercent = (frameTime - previousInputTime) / (inputFrameTime - previousInputTime);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user