Revert "Noise::perlinMap2D,3D: replace a loop init with a single memset call"
authorLoïc Blot <loic.blot@unix-experience.fr>
Thu, 27 Jul 2017 15:12:18 +0000 (17:12 +0200)
committerLoïc Blot <loic.blot@unix-experience.fr>
Thu, 27 Jul 2017 15:12:18 +0000 (17:12 +0200)
This reverts commit bc1654feedc90caa8c26328ca6f0fc59fbe5b76c.

src/noise.cpp

index e68c5ce168648a6c9e32c3ff7e3bf69bb888de8f..f67771b8885e3679b90cc7619cccfd1d73bbedb1 100644 (file)
@@ -713,7 +713,8 @@ float *Noise::perlinMap2D(float x, float y, float *persistence_map)
        if (persistence_map) {
                if (!persist_buf)
                        persist_buf = new float[bufsize];
-               memset(persist_buf, 1.0f, sizeof(float) * bufsize);
+               for (size_t i = 0; i != bufsize; i++)
+                       persist_buf[i] = 1.0;
        }
 
        for (size_t oct = 0; oct < np.octaves; oct++) {
@@ -750,8 +751,8 @@ float *Noise::perlinMap3D(float x, float y, float z, float *persistence_map)
        if (persistence_map) {
                if (!persist_buf)
                        persist_buf = new float[bufsize];
-
-               memset(persist_buf, 1.0f, sizeof(float) * bufsize);
+               for (size_t i = 0; i != bufsize; i++)
+                       persist_buf[i] = 1.0;
        }
 
        for (size_t oct = 0; oct < np.octaves; oct++) {