afritz1 / OpenTESArena

Open-source re-implementation of The Elder Scrolls: Arena.
MIT License
915 stars 68 forks source link

Last frame of entity animations might be sticking for an extra game frame #197

Closed afritz1 closed 1 year ago

afritz1 commented 3 years ago

This is easier to see at a lower FPS like 10 or 15. I wanted to avoid a while loop there since that would probably be too slow for thousands of entities.

https://github.com/afritz1/OpenTESArena/blob/f75383f6a302655049193001330738608bdabec5/OpenTESArena/src/Entities/EntityAnimationInstance.cpp#L167

afritz1 commented 3 years ago

I might be misunderstanding the problem and this is just how it would be due to beat frequencies or something? Anyway, changing it to this seems to have no change:

this->currentSeconds += dt;
if (looping)
{
    while (this->currentSeconds >= totalSeconds)
    {
        this->currentSeconds -= totalSeconds;
    }
}
afritz1 commented 1 year ago

I think this was fixed with the software renderer part 1 refactor. It's still kind of noticeable but it isn't always the last frame, so I think it's a beat frequency thing that varies based on the difference between the entity's frame rate and the game's, which is okay.