diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-09-12 16:26:44 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-09-12 16:26:44 -0700 |
commit | 643148737f38151d7bfdec1ad45718f5616e0ac9 (patch) | |
tree | 1410ed308bf8caae9eaa63e81efd6dac899b9e26 /src/modules/spiro/spiro.c | |
parent | c8e59d7361931ad2a3f3ba5911d7250a36bf4dfc (diff) |
modules/spiro: use ticks instead of time() w/srand
time() only changes every second, so this had the effect of freezing
the seed a second at a time, affecting all rand() users, when spiro's
create_context() was called more frequently than 1HZ.
When using rtv with channels=spiro,duration=0 the create_context() gets
called every other frame, and the visual results were very broken with
the spiro only actually reseeding every second and the snow between each
frame being static since it too uses rand() for seeding itself.
This whole situation suggests no module should be calling srand(), and
instead rototiller should probably call srand() once at startup and any
modules that wish to use rand with a different seed should use rand_r(),
and maybe rand() just for acquiring the seed like modules/snow does.
Diffstat (limited to 'src/modules/spiro/spiro.c')
-rw-r--r-- | src/modules/spiro/spiro.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c index b404c75..6234744 100644 --- a/src/modules/spiro/spiro.c +++ b/src/modules/spiro/spiro.c @@ -37,7 +37,7 @@ static void * spiro_create_context(unsigned ticks, unsigned num_cpus) if (!ctxt) return NULL; - srand(time(NULL) + getpid()); + srand(ticks + getpid()); ctxt->r=.25f+(rand()/(float)RAND_MAX)*.5f; if(ctxt->r>.5f) |