Skip to content

Commit 3b65870

Browse files
committed
Remove trailing whitespace
1 parent c70b0c1 commit 3b65870

File tree

3 files changed

+37
-38
lines changed

3 files changed

+37
-38
lines changed

_noise.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#endif
1212

1313
const float GRAD3[][3] = {
14-
{1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0},
15-
{1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1},
14+
{1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0},
15+
{1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1},
1616
{0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1},
1717
{1,0,-1},{-1,0,-1},{0,-1,1},{0,1,1}};
1818

@@ -70,7 +70,7 @@ const unsigned char SIMPLEX[][4] = {
7070
{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0},{1,0,2,3},{1,0,3,2},{0,0,0,0},
7171
{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0},{0,0,0,0},{0,0,0,0},
7272
{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,1,3},
73-
{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0},
73+
{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0},
7474
{2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},
7575
{3,2,1,0}};
7676

@@ -106,4 +106,3 @@ inline float fast_cos(float x)
106106
{
107107
return fast_sin(x + 0.5f);
108108
}
109-

_perlin.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ py_noise1(PyObject *self, PyObject *args, PyObject *kwargs)
5353
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "f|iffii:noise1", kwlist,
5454
&x, &octaves, &persistence, &lacunarity, &repeat, &base))
5555
return NULL;
56-
56+
5757
if (octaves == 1) {
5858
// Single octave, return simple noise
5959
return (PyObject *) PyFloat_FromDouble((double) noise1(x, repeat, base));
@@ -108,7 +108,7 @@ noise2(float x, float y, const float repeatx, const float repeaty, const int bas
108108
B = PERM[ii];
109109
BA = PERM[B + j];
110110
BB = PERM[B + jj];
111-
111+
112112
return lerp(fy, lerp(fx, grad2(PERM[AA], x, y),
113113
grad2(PERM[BA], x - 1, y)),
114114
lerp(fx, grad2(PERM[AB], x, y - 1),
@@ -131,7 +131,7 @@ py_noise2(PyObject *self, PyObject *args, PyObject *kwargs)
131131
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ff|iffffi:noise2", kwlist,
132132
&x, &y, &octaves, &persistence, &lacunarity, &repeatx, &repeaty, &base))
133133
return NULL;
134-
134+
135135
if (octaves == 1) {
136136
// Single octave, return simple noise
137137
return (PyObject *) PyFloat_FromDouble((double) noise2(x, y, repeatx, repeaty, base));
@@ -163,7 +163,7 @@ grad3(const int hash, const float x, const float y, const float z)
163163
}
164164

165165
float
166-
noise3(float x, float y, float z, const int repeatx, const int repeaty, const int repeatz,
166+
noise3(float x, float y, float z, const int repeatx, const int repeaty, const int repeatz,
167167
const int base)
168168
{
169169
float fx, fy, fz;
@@ -192,7 +192,7 @@ noise3(float x, float y, float z, const int repeatx, const int repeaty, const in
192192
B = PERM[ii];
193193
BA = PERM[B + j];
194194
BB = PERM[B + jj];
195-
195+
196196
return lerp(fz, lerp(fy, lerp(fx, grad3(PERM[AA + k], x, y, z),
197197
grad3(PERM[BA + k], x - 1, y, z)),
198198
lerp(fx, grad3(PERM[AB + k], x, y - 1, z),
@@ -221,10 +221,10 @@ py_noise3(PyObject *self, PyObject *args, PyObject *kwargs)
221221
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "fff|iffiiii:noise3", kwlist,
222222
&x, &y, &z, &octaves, &persistence, &lacunarity, &repeatx, &repeaty, &repeatz, &base))
223223
return NULL;
224-
224+
225225
if (octaves == 1) {
226226
// Single octave, return simple noise
227-
return (PyObject *) PyFloat_FromDouble((double) noise3(x, y, z,
227+
return (PyObject *) PyFloat_FromDouble((double) noise3(x, y, z,
228228
repeatx, repeaty, repeatz, base));
229229
} else if (octaves > 1) {
230230
int i;
@@ -234,7 +234,7 @@ py_noise3(PyObject *self, PyObject *args, PyObject *kwargs)
234234
float total = 0.0f;
235235

236236
for (i = 0; i < octaves; i++) {
237-
total += noise3(x * freq, y * freq, z * freq,
237+
total += noise3(x * freq, y * freq, z * freq,
238238
(const int)(repeatx*freq), (const int)(repeaty*freq), (const int)(repeatz*freq), base) * amp;
239239
max += amp;
240240
freq *= lacunarity;
@@ -248,13 +248,13 @@ py_noise3(PyObject *self, PyObject *args, PyObject *kwargs)
248248
}
249249

250250
static PyMethodDef perlin_functions[] = {
251-
{"noise1", (PyCFunction) py_noise1, METH_VARARGS | METH_KEYWORDS,
251+
{"noise1", (PyCFunction) py_noise1, METH_VARARGS | METH_KEYWORDS,
252252
"noise1(x, octaves=1, persistence=0.5, lacunarity=2.0, repeat=1024, base=0.0)\n\n"
253253
"1 dimensional perlin improved noise function (see noise3 for more info)"},
254-
{"noise2", (PyCFunction) py_noise2, METH_VARARGS | METH_KEYWORDS,
254+
{"noise2", (PyCFunction) py_noise2, METH_VARARGS | METH_KEYWORDS,
255255
"noise2(x, y, octaves=1, persistence=0.5, lacunarity=2.0, repeatx=1024, repeaty=1024, base=0.0)\n\n"
256256
"2 dimensional perlin improved noise function (see noise3 for more info)"},
257-
{"noise3", (PyCFunction) py_noise3, METH_VARARGS | METH_KEYWORDS,
257+
{"noise3", (PyCFunction) py_noise3, METH_VARARGS | METH_KEYWORDS,
258258
"noise3(x, y, z, octaves=1, persistence=0.5, lacunarity=2.0, "
259259
"repeatx=1024, repeaty=1024, repeatz=1024, base=0.0)\n\n"
260260
"return perlin \"improved\" noise value for specified coordinate\n\n"

_simplex.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
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
153153
noise4(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

377377
static 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

Comments
 (0)