From d9ef78ae11efaf88bcf2b964778890108084193b Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 25 Jan 2020 21:43:07 -0800 Subject: modules/flui2d: derive r from ticks Modulo ticks by 2*M_PI to preserve precision by constraining the float to 2*M_PI radians. --- src/modules/flui2d/flui2d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index 62dbbec..71238cd 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -218,8 +218,8 @@ static int flui2d_fragmenter(void *context, const fb_fragment_t *fragment, unsig static void flui2d_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter) { flui2d_context_t *ctxt = context; - static float r; - int x = (cos(r += .01f) * .4f + .5f) * (float)ROOT; /* figure eight pattern for the added densities */ + float r = (ticks % (unsigned)(2 * M_PI * 1000)) * .001f; + int x = (cos(r) * .4f + .5f) * (float)ROOT; /* figure eight pattern for the added densities */ int y = (sin(r * 2.f) * .4f + .5f) * (float)ROOT; *res_fragmenter = flui2d_fragmenter; -- cgit v1.2.1