Update "open-simplex-noise-in-c" to fix undefined signed overflow.
This commit is contained in:
parent
593e35346a
commit
70bdf0ecf2
2 changed files with 7 additions and 6 deletions
2
thirdparty/README.md
vendored
2
thirdparty/README.md
vendored
|
@ -378,7 +378,7 @@ Collection of single-file libraries used in Godot components.
|
||||||
* License: Apache 2.0
|
* License: Apache 2.0
|
||||||
- `open-simplex-noise.{c,h}`
|
- `open-simplex-noise.{c,h}`
|
||||||
* Upstream: https://github.com/smcameron/open-simplex-noise-in-c
|
* Upstream: https://github.com/smcameron/open-simplex-noise-in-c
|
||||||
* Version: git (0d555e7f40527d0870906fe9469a3b1bb4020b7f, 2015) + custom changes
|
* Version: git (0fef0dbedd76f767da7e3c894822729d0f07e54d, 2020) + custom changes
|
||||||
* License: Unlicense
|
* License: Unlicense
|
||||||
- `pcg.{cpp,h}`
|
- `pcg.{cpp,h}`
|
||||||
* Upstream: http://www.pcg-random.org
|
* Upstream: http://www.pcg-random.org
|
||||||
|
|
11
thirdparty/misc/open-simplex-noise.c
vendored
11
thirdparty/misc/open-simplex-noise.c
vendored
|
@ -189,14 +189,15 @@ int open_simplex_noise(int64_t seed, struct osn_context *ctx)
|
||||||
permGradIndex3D = ctx->permGradIndex3D;
|
permGradIndex3D = ctx->permGradIndex3D;
|
||||||
// -- GODOT end --
|
// -- GODOT end --
|
||||||
|
|
||||||
|
uint64_t seedU = seed;
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
source[i] = (int16_t) i;
|
source[i] = (int16_t) i;
|
||||||
seed = seed * 6364136223846793005LL + 1442695040888963407LL;
|
seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
|
||||||
seed = seed * 6364136223846793005LL + 1442695040888963407LL;
|
seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
|
||||||
seed = seed * 6364136223846793005LL + 1442695040888963407LL;
|
seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
|
||||||
for (i = 255; i >= 0; i--) {
|
for (i = 255; i >= 0; i--) {
|
||||||
seed = seed * 6364136223846793005LL + 1442695040888963407LL;
|
seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
|
||||||
r = (int)((seed + 31) % (i + 1));
|
r = (int)((seedU + 31) % (i + 1));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
r += (i + 1);
|
r += (i + 1);
|
||||||
perm[i] = source[r];
|
perm[i] = source[r];
|
||||||
|
|
Loading…
Reference in a new issue