aboutsummaryrefslogtreecommitdiff
path: root/src/noise.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/noise.cpp')
-rw-r--r--src/noise.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/noise.cpp b/src/noise.cpp
index 2948fb765..b1b702538 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -158,21 +158,21 @@ s32 PcgRandom::randNormalDist(s32 min, s32 max, int num_trials)
float noise2d(int x, int y, int seed)
{
- int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y
+ unsigned int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
n = (n >> 13) ^ n;
n = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
- return 1.f - (float)n / 0x40000000;
+ return 1.f - (float)(int)n / 0x40000000;
}
float noise3d(int x, int y, int z, int seed)
{
- int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y + NOISE_MAGIC_Z * z
+ unsigned int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y + NOISE_MAGIC_Z * z
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
n = (n >> 13) ^ n;
n = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
- return 1.f - (float)n / 0x40000000;
+ return 1.f - (float)(int)n / 0x40000000;
}