From 8c55bc5376ae2740bccddf7fa0f4aeec851d0144 Mon Sep 17 00:00:00 2001 From: ntark Date: Sat, 7 Dec 2024 13:09:08 +0400 Subject: [PATCH] fix issues #7 and #8: disconnects for custom seeds, add .gitignore file --- .gitignore | 9 +++++++++ SimplexNoise/Noise.cs | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f64ee3b --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Visual Studio 2015/2017 cache/options directory +.vs/ + +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ diff --git a/SimplexNoise/Noise.cs b/SimplexNoise/Noise.cs index 25a5090..fe9ebba 100644 --- a/SimplexNoise/Noise.cs +++ b/SimplexNoise/Noise.cs @@ -120,9 +120,14 @@ public static int Seed } else { + // permutation matrix is duplicated to handle rollovers _perm = new byte[512]; - var random = new Random(value); - random.NextBytes(_perm); + + var perm = new byte[256]; + new Random(value).NextBytes(perm); + + Array.Copy(perm, 0, _perm, 0, 256); + Array.Copy(perm, 0, _perm, 256, 256); } _seed = value;