[gegl] gegl:perlin-noise: use a local random generator for initializing
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl:perlin-noise: use a local random generator for initializing
- Date: Thu, 30 Jul 2020 09:48:11 +0000 (UTC)
commit 8fbdf0c5637a7e7c72db944982c5afd0c1b9ceb6
Author: Tatsuki Makino <tatsuki_makino hotmail com>
Date: Thu Jul 30 11:43:35 2020 +0200
gegl:perlin-noise: use a local random generator for initializing
Settin gthe global seed with g_random_set_seed impacts programs
using GEGL, for instance the random splash feature in GIMP had
become deterministic.
operations/common/perlin/perlin.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/operations/common/perlin/perlin.c b/operations/common/perlin/perlin.c
index 400c27183..9d3882930 100644
--- a/operations/common/perlin/perlin.c
+++ b/operations/common/perlin/perlin.c
@@ -7,7 +7,7 @@
#include "perlin.h"
/* random is not portable to all platforms */
-#define random g_random_int
+#define random() g_rand_int (gr)
static int p[B + B + 2];
static double g3[B + B + 2][3];
@@ -150,8 +150,7 @@ perlin_init (void)
if (initialized)
return;
/* this is racy - but we call it once when creating our perlin noise op */
-
- g_random_set_seed (1234567890);
+ GRand *gr = g_rand_new_with_seed (1234567890);
for (i = 0; i < B; i++)
{
@@ -184,6 +183,7 @@ perlin_init (void)
g3[B + i][j] = g3[i][j];
}
initialized = 1;
+ g_rand_free (gr);
}
/* --- My harmonic summing functions - PDB --------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]