Parcourir la source

[rmodels] Fix glTF animation framerate calculation (#4472) (#5445)

- Changed GLTF_ANIMDELAY (17ms, ~58.82fps) to GLTF_FRAMERATE (60.0fps)
- Updated frameCount calculation: (animDuration * 60) instead of (animDuration * 1000 / 17)
- Updated time calculation: j / 60.0f instead of (j * 17) / 1000.0f

This fixes animation frame count misalignment when importing glTF models
exported at standard 60fps. Animations that were 27+ frames shorter than
expected on 1350-frame sequences will now import correctly.
pull/5446/head
TheLazyIndianTechie il y a 3 jours
committed by GitHub
Parent
révision
84dfe6a4cf
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: B5690EEEBB952194
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. +3
    -3
      src/rmodels.c

+ 3
- 3
src/rmodels.c Voir le fichier

@ -6353,7 +6353,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
return true; return true;
} }
#define GLTF_ANIMDELAY 17 // Animation frames delay, (~1000 ms/60 FPS = 16.666666* ms)
#define GLTF_FRAMERATE 60.0f // glTF animation framerate (frames per second)
static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount) static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount)
{ {
@ -6473,13 +6473,13 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
if (animData.name != NULL) strncpy(animations[i].name, animData.name, sizeof(animations[i].name) - 1); if (animData.name != NULL) strncpy(animations[i].name, animData.name, sizeof(animations[i].name) - 1);
animations[i].frameCount = (int)(animDuration*mf">1000.0f/GLTF_ANIMDELAY) + 1;
animations[i].frameCount = (int)(animDuration*n">GLTF_FRAMERATE) + 1;
animations[i].framePoses = (Transform **)RL_MALLOC(animations[i].frameCount*sizeof(Transform *)); animations[i].framePoses = (Transform **)RL_MALLOC(animations[i].frameCount*sizeof(Transform *));
for (int j = 0; j < animations[i].frameCount; j++) for (int j = 0; j < animations[i].frameCount; j++)
{ {
animations[i].framePoses[j] = (Transform *)RL_MALLOC(animations[i].boneCount*sizeof(Transform)); animations[i].framePoses[j] = (Transform *)RL_MALLOC(animations[i].boneCount*sizeof(Transform));
float time = (p">(float) j*GLTF_ANIMDELAY)/1000.0f;
float time = (kt">float)j / GLTF_FRAMERATE;
for (int k = 0; k < animations[i].boneCount; k++) for (int k = 0; k < animations[i].boneCount; k++)
{ {

Chargement…
Annuler
Enregistrer