Skip to content

[rmodels] glTF animation import uses odd framerate as basis for time to frame conversion #4472

Open
@aeaeaeaeaeae

Description

@aeaeaeaeaeae

Issue description

Model animation .glb exported at 60fps will not get matching frames when loaded into raylib. This is because raylib uses an odd conversion factor when translating from time to frame during load. For longer animation sequences this become significant, at 1350 frames my animation was 27 frames shorter than it was supposed to be. I guess it's a bug, unless theres a special reason for using 58.8235fps as import basis.

// rmodel.c
#define GLTF_ANIMDELAY 17    // Animation frames delay, (~1000 ms/60 FPS = 16.666666* ms)
static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount)
{
...
animations[i].frameCount = (int)(animDuration*1000.0f/GLTF_ANIMDELAY) + 1;
animations[i].framePoses = RL_MALLOC(animations[i].frameCount*sizeof(Transform *));
...
float time = ((float) j*GLTF_ANIMDELAY)/1000.0f;
}

Not sure if it's implemented like this for a reason, but wouldn't it be alot simpler to just use 60fps as a base instead?

const float GLTF_FRAMERATE  = 60.0f;

animations[i].frameCount = (int)(animDuration*GLTF_FRAMERATE) + 1;
animations[i].framePoses = RL_MALLOC(animations[i].frameCount*sizeof(Transform *));

float time = j*(1.0/GLTF_FRAMERATE);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions