Просмотр исходного кода

[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 2 дней назад
committed by GitHub
Родитель
Сommit
84dfe6a4cf
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: B5690EEEBB952194
1 измененных файлов: 3 добавлений и 3 удалений
  1. +3
    -3
      src/rmodels.c

+ 3
- 3
src/rmodels.c Просмотреть файл

@ -6353,7 +6353,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
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)
{
@ -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);
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 *));
for (int j = 0; j < animations[i].frameCount; j++)
{
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++)
{

Загрузка…
Отмена
Сохранить