1212#define F2 0.3660254037844386f // 0.5 * (sqrt(3.0) - 1.0)
1313#define G2 0.21132486540518713f // (3.0 - sqrt(3.0)) / 6.0
1414
15- float
16- noise2 (float x , float y )
15+ float
16+ noise2 (float x , float y )
1717{
1818 int i1 , j1 , I , J , c ;
1919 float s = (x + y ) * F2 ;
@@ -44,11 +44,11 @@ noise2(float x, float y)
4444
4545 for (c = 0 ; c <= 2 ; c ++ )
4646 f [c ] = 0.5f - xx [c ]* xx [c ] - yy [c ]* yy [c ];
47-
47+
4848 for (c = 0 ; c <= 2 ; c ++ )
4949 if (f [c ] > 0 )
5050 noise [c ] = f [c ]* f [c ]* f [c ]* f [c ] * (GRAD3 [g [c ]][0 ]* xx [c ] + GRAD3 [g [c ]][1 ]* yy [c ]);
51-
51+
5252 return (noise [0 ] + noise [1 ] + noise [2 ]) * 70.0f ;
5353}
5454
@@ -59,8 +59,8 @@ noise2(float x, float y)
5959#define F3 (1.0f / 3.0f)
6060#define G3 (1.0f / 6.0f)
6161
62- float
63- noise3 (float x , float y , float z )
62+ float
63+ noise3 (float x , float y , float z )
6464{
6565 int c , o1 [3 ], o2 [3 ], g [4 ], I , J , K ;
6666 float f [4 ], noise [4 ] = {0.0f , 0.0f , 0.0f , 0.0f };
@@ -99,31 +99,31 @@ noise3(float x, float y, float z)
9999 ASSIGN (o2 , 1 , 1 , 0 );
100100 }
101101 }
102-
102+
103103 for (c = 0 ; c <= 2 ; c ++ ) {
104104 pos [3 ][c ] = pos [0 ][c ] - 1.0f + 3.0f * G3 ;
105105 pos [2 ][c ] = pos [0 ][c ] - o2 [c ] + 2.0f * G3 ;
106106 pos [1 ][c ] = pos [0 ][c ] - o1 [c ] + G3 ;
107107 }
108108
109- I = (int ) i & 255 ;
110- J = (int ) j & 255 ;
109+ I = (int ) i & 255 ;
110+ J = (int ) j & 255 ;
111111 K = (int ) k & 255 ;
112112 g [0 ] = PERM [I + PERM [J + PERM [K ]]] % 12 ;
113113 g [1 ] = PERM [I + o1 [0 ] + PERM [J + o1 [1 ] + PERM [o1 [2 ] + K ]]] % 12 ;
114114 g [2 ] = PERM [I + o2 [0 ] + PERM [J + o2 [1 ] + PERM [o2 [2 ] + K ]]] % 12 ;
115- g [3 ] = PERM [I + 1 + PERM [J + 1 + PERM [K + 1 ]]] % 12 ;
115+ g [3 ] = PERM [I + 1 + PERM [J + 1 + PERM [K + 1 ]]] % 12 ;
116116
117117 for (c = 0 ; c <= 3 ; c ++ ) {
118118 f [c ] = 0.6f - pos [c ][0 ]* pos [c ][0 ] - pos [c ][1 ]* pos [c ][1 ] - pos [c ][2 ]* pos [c ][2 ];
119119 }
120-
120+
121121 for (c = 0 ; c <= 3 ; c ++ ) {
122122 if (f [c ] > 0 ) {
123123 noise [c ] = f [c ]* f [c ]* f [c ]* f [c ] * dot3 (pos [c ], GRAD3 [g [c ]]);
124124 }
125125 }
126-
126+
127127 return (noise [0 ] + noise [1 ] + noise [2 ] + noise [3 ]) * 32.0f ;
128128}
129129
@@ -149,7 +149,7 @@ fbm_noise3(float x, float y, float z, int octaves, float persistence, float lacu
149149#define F4 0.30901699437494745f /* (sqrt(5.0) - 1.0) / 4.0 */
150150#define G4 0.1381966011250105f /* (5.0 - sqrt(5.0)) / 20.0 */
151151
152- float
152+ float
153153noise4 (float x , float y , float z , float w ) {
154154 float noise [5 ] = {0.0f , 0.0f , 0.0f , 0.0f , 0.0f };
155155
@@ -201,9 +201,9 @@ noise4(float x, float y, float z, float w) {
201201 int K = (int )k & 255 ;
202202 int L = (int )l & 255 ;
203203 int gi0 = PERM [I + PERM [J + PERM [K + PERM [L ]]]] & 0x1f ;
204- int gi1 = PERM [I + i1 + PERM [J + j1 + PERM [K + k1 + PERM [L + l1 ]]]] & 0x1f ;
205- int gi2 = PERM [I + i2 + PERM [J + j2 + PERM [K + k2 + PERM [L + l2 ]]]] & 0x1f ;
206- int gi3 = PERM [I + i3 + PERM [J + j3 + PERM [K + k3 + PERM [L + l3 ]]]] & 0x1f ;
204+ int gi1 = PERM [I + i1 + PERM [J + j1 + PERM [K + k1 + PERM [L + l1 ]]]] & 0x1f ;
205+ int gi2 = PERM [I + i2 + PERM [J + j2 + PERM [K + k2 + PERM [L + l2 ]]]] & 0x1f ;
206+ int gi3 = PERM [I + i3 + PERM [J + j3 + PERM [K + k3 + PERM [L + l3 ]]]] & 0x1f ;
207207 int gi4 = PERM [I + 1 + PERM [J + 1 + PERM [K + 1 + PERM [L + 1 ]]]] & 0x1f ;
208208 float t0 , t1 , t2 , t3 , t4 ;
209209
@@ -264,7 +264,7 @@ py_noise2(PyObject *self, PyObject *args, PyObject *kwargs)
264264 float repeatx = FLT_MAX ;
265265 float repeaty = FLT_MAX ;
266266 float z = 0.0f ;
267- static char * kwlist [] = {"x" , "y" , "octaves" , "persistence" , "lacunarity" ,
267+ static char * kwlist [] = {"x" , "y" , "octaves" , "persistence" , "lacunarity" ,
268268 "repeatx" , "repeaty" , "base" , NULL };
269269
270270 if (!PyArg_ParseTupleAndKeywords (args , kwargs , "ff|ifffff:snoise2" , kwlist ,
@@ -275,7 +275,7 @@ py_noise2(PyObject *self, PyObject *args, PyObject *kwargs)
275275 PyErr_SetString (PyExc_ValueError , "Expected octaves value > 0" );
276276 return NULL ;
277277 }
278-
278+
279279 if (repeatx == FLT_MAX && repeaty == FLT_MAX ) {
280280 // Flat noise, no tiling
281281 float freq = 1.0f ;
@@ -335,7 +335,7 @@ py_noise3(PyObject *self, PyObject *args, PyObject *kwargs)
335335 if (!PyArg_ParseTupleAndKeywords (args , kwargs , "fff|iff:snoise3" , kwlist ,
336336 & x , & y , & z , & octaves , & persistence , & lacunarity ))
337337 return NULL ;
338-
338+
339339 if (octaves == 1 ) {
340340 // Single octave, return simple noise
341341 return (PyObject * ) PyFloat_FromDouble ((double ) noise3 (x , y , z ));
@@ -361,7 +361,7 @@ py_noise4(PyObject *self, PyObject *args, PyObject *kwargs)
361361 if (!PyArg_ParseTupleAndKeywords (args , kwargs , "ffff|iff:snoise4" , kwlist ,
362362 & x , & y , & z , & w , & octaves , & persistence ))
363363 return NULL ;
364-
364+
365365 if (octaves == 1 ) {
366366 // Single octave, return simple noise
367367 return (PyObject * ) PyFloat_FromDouble ((double ) noise4 (x , y , z , w ));
@@ -375,7 +375,7 @@ py_noise4(PyObject *self, PyObject *args, PyObject *kwargs)
375375}
376376
377377static PyMethodDef simplex_functions [] = {
378- {"noise2" , (PyCFunction )py_noise2 , METH_VARARGS | METH_KEYWORDS ,
378+ {"noise2" , (PyCFunction )py_noise2 , METH_VARARGS | METH_KEYWORDS ,
379379 "noise2(x, y, octaves=1, persistence=0.5, lacunarity=2.0, repeatx=None, repeaty=None, base=0.0) "
380380 "return simplex noise value for specified 2D coordinate.\n\n"
381381 "octaves -- specifies the number of passes, defaults to 1 (simple noise).\n\n"
@@ -389,7 +389,7 @@ static PyMethodDef simplex_functions[] = {
389389 "tileable textures\n\n"
390390 "base -- specifies a fixed offset for the noise coordinates. Useful for\n"
391391 "generating different noise textures with the same repeat interval" },
392- {"noise3" , (PyCFunction )py_noise3 , METH_VARARGS | METH_KEYWORDS ,
392+ {"noise3" , (PyCFunction )py_noise3 , METH_VARARGS | METH_KEYWORDS ,
393393 "noise3(x, y, z, octaves=1, persistence=0.5, lacunarity=2.0) return simplex noise value for "
394394 "specified 3D coordinate\n\n"
395395 "octaves -- specifies the number of passes, defaults to 1 (simple noise).\n\n"
@@ -398,7 +398,7 @@ static PyMethodDef simplex_functions[] = {
398398 "is halved). Note the amplitude of the first pass is always 1.0.\n\n"
399399 "lacunarity -- specifies the frequency of each successive octave relative\n"
400400 "to the one below it, similar to persistence. Defaults to 2.0." },
401- {"noise4" , (PyCFunction )py_noise4 , METH_VARARGS | METH_KEYWORDS ,
401+ {"noise4" , (PyCFunction )py_noise4 , METH_VARARGS | METH_KEYWORDS ,
402402 "noise4(x, y, z, w, octaves=1, persistence=0.5, lacunarity=2.0) return simplex noise value for "
403403 "specified 4D coordinate\n\n"
404404 "octaves -- specifies the number of passes, defaults to 1 (simple noise).\n\n"
0 commit comments