]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fractalnoise.c
Very minor speedup to fractal noise generator.
[xonotic/darkplaces.git] / fractalnoise.c
index b663027943a24de5409e1c35cec484c00af22230..68f375ed2b4e414ca13b4993bca3ac345fe1f551 100644 (file)
@@ -3,7 +3,7 @@
 
 void fractalnoise(unsigned char *noise, int size)
 {
-       int x, y, g, g2, amplitude, amplitude2, min, max, size1 = size - 1;
+       int x, y, g, g2, amplitude, min, max, size1 = size - 1;
        int *noisebuf;
 #define n(x,y) noisebuf[((y)&size1)*size+((x)&size1)]
        noisebuf = calloc(size*size, sizeof(int));
@@ -27,10 +27,9 @@ void fractalnoise(unsigned char *noise, int size)
                        }
                // brownian motion theory
                amplitude >>= 1;
-               amplitude2 = amplitude >> 1;
                for (y = 0;y < size;y += g)
                        for (x = 0;x < size;x += g)
-                               n(x,y) += (rand()&amplitude) - amplitude2;
+                               n(x,y) += (rand()&amplitude);
        }
        // find range of noise values
        min = max = 0;