From 1592b40e25f421f609ecd218562cb06010838040 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 22 Aug 2016 15:52:11 +0200 Subject: [PATCH] Fix particles stutter caused by malformed timeout Closes #836. --- examples/particles.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/particles.c b/examples/particles.c index a035cb1e..4a65ab12 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -457,7 +457,9 @@ static void draw_particles(GLFWwindow* window, double t, float dt) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_nsec += 100000000; + ts.tv_nsec += 100 * 1000 * 1000; + ts.tv_sec += ts.tv_nsec / (1000 * 1000 * 1000); + ts.tv_nsec %= 1000 * 1000 * 1000; cnd_timedwait(&thread_sync.p_done, &thread_sync.particles_lock, &ts); } @@ -908,7 +910,9 @@ static int physics_thread_main(void* arg) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_nsec += 100000000; + ts.tv_nsec += 100 * 1000 * 1000; + ts.tv_sec += ts.tv_nsec / (1000 * 1000 * 1000); + ts.tv_nsec %= 1000 * 1000 * 1000; cnd_timedwait(&thread_sync.d_done, &thread_sync.particles_lock, &ts); }