diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-01-25 21:43:07 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-01-25 21:43:07 -0800 |
commit | d9ef78ae11efaf88bcf2b964778890108084193b (patch) | |
tree | 27f66ffa321c96a55ba0b2d45379614c06f8a64d /src | |
parent | ea778644eb3e2df22122c79c5e8a8a9e99490beb (diff) |
modules/flui2d: derive r from ticks
Modulo ticks by 2*M_PI to preserve precision by constraining the float
to 2*M_PI radians.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/flui2d/flui2d.c | 4 |
1 files changed, 2 insertions, 2 deletions
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; |