example: more precisely calculate frame numbers
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run

fixed a missing case of the last frame.
This commit is contained in:
Hermet Park 2025-06-25 18:54:57 +09:00
parent 05e4c3e4eb
commit 43923a54d4

View file

@ -496,10 +496,10 @@ struct WgWindow : Window
float progress(uint32_t elapsed, float durationInSec, bool rewind = false)
{
auto duration = uint32_t(durationInSec * 1000.0f); //sec -> millisec.
if (duration == 0) return 0.0f;
if (elapsed == 0 || duration == 0) return 0.0f;
auto forward = ((elapsed / duration) % 2 == 0) ? true : false;
auto wrapped = elapsed % duration;
auto progress = ((float)wrapped / (float)duration);
if (elapsed % duration == 0) return 1.0f;
auto progress = (float(elapsed % duration) / (float)duration);
if (rewind) return forward ? progress : (1 - progress);
return progress;
}