]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fractalnoise.c
changed master server list around a bit (added rick.cube-sol.net and my master server...
[xonotic/darkplaces.git] / fractalnoise.c
index ad9d91ed4a0ab1b0a4bf7a396483c3047f8bc987..06d00db0eedbc805291b94771b13178d17bbcc42 100644 (file)
@@ -1,7 +1,7 @@
 
 #include "quakedef.h"
 
-void fractalnoise(byte *noise, int size, int startgrid)
+void fractalnoise(qbyte *noise, int size, int startgrid)
 {
        int x, y, g, g2, amplitude, min, max, size1 = size - 1, sizepower, gridpower;
        int *noisebuf;
@@ -32,7 +32,7 @@ void fractalnoise(byte *noise, int size, int startgrid)
                g = g2 >> 1;
                if (g)
                {
-                       // subdivide, diamond-square algorythm (really this has little to do with squares)
+                       // subdivide, diamond-square algorithm (really this has little to do with squares)
                        // diamond
                        for (y = 0;y < size;y += g2)
                                for (x = 0;x < size;x += g2)
@@ -59,13 +59,13 @@ void fractalnoise(byte *noise, int size, int startgrid)
        // normalize noise and copy to output
        for (y = 0;y < size;y++)
                for (x = 0;x < size;x++)
-                       *noise++ = (byte) (((n(x,y) - min) * 256) / max);
+                       *noise++ = (qbyte) (((n(x,y) - min) * 256) / max);
        Mem_Free(noisebuf);
 #undef n
 }
 
 // unnormalized, used for explosions mainly, does not allocate/free memory (hence the name quick)
-void fractalnoisequick(byte *noise, int size, int startgrid)
+void fractalnoisequick(qbyte *noise, int size, int startgrid)
 {
        int x, y, g, g2, amplitude, size1 = size - 1, sizepower, gridpower;
 #define n(x,y) noise[((y)&size1)*size+((x)&size1)]
@@ -94,19 +94,20 @@ void fractalnoisequick(byte *noise, int size, int startgrid)
                g = g2 >> 1;
                if (g)
                {
-                       // subdivide, diamond-square algorythm (really this has little to do with squares)
+                       // subdivide, diamond-square algorithm (really this has little to do with squares)
                        // diamond
                        for (y = 0;y < size;y += g2)
                                for (x = 0;x < size;x += g2)
-                                       n(x+g,y+g) = (byte) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x,y+g2) + (int) n(x+g2,y+g2)) >> 2);
+                                       n(x+g,y+g) = (qbyte) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x,y+g2) + (int) n(x+g2,y+g2)) >> 2);
                        // square
                        for (y = 0;y < size;y += g2)
                                for (x = 0;x < size;x += g2)
                                {
-                                       n(x+g,y) = (byte) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x+g,y-g) + (int) n(x+g,y+g)) >> 2);
-                                       n(x,y+g) = (byte) (((int) n(x,y) + (int) n(x,y+g2) + (int) n(x-g,y+g) + (int) n(x+g,y+g)) >> 2);
+                                       n(x+g,y) = (qbyte) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x+g,y-g) + (int) n(x+g,y+g)) >> 2);
+                                       n(x,y+g) = (qbyte) (((int) n(x,y) + (int) n(x,y+g2) + (int) n(x-g,y+g) + (int) n(x+g,y+g)) >> 2);
                                }
                }
        }
 #undef n
 }
+