Skip to content

Commit d1dd02d

Browse files
committed
compact the SuperSimplex static kernel code
1 parent 9b540bd commit d1dd02d

File tree

1 file changed

+5
-45
lines changed

1 file changed

+5
-45
lines changed

sources/noise/gradient.swift

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -238,52 +238,12 @@ struct SuperSimplexNoise2D:GradientNoise2D
238238
var points:[LatticePoint] = []
239239
points.reserveCapacity(32)
240240

241-
for n in 0 ..< 8
241+
for (i1, j1, i2, j2):(Int, Int, Int, Int) in
242+
[
243+
(-1, 0, 0, -1), (0, 1, 1, 0), (1, 0, 0, -1), (2, 1, 1, 0),
244+
(-1, 0, 0, 1), (0, 1, 1, 2), (1, 0, 0, 1), (2, 1, 1, 2)
245+
]
242246
{
243-
let i1:Int, j1:Int,
244-
i2:Int, j2:Int
245-
246-
if n & 1 != 0
247-
{
248-
if n & 2 != 0
249-
{
250-
i1 = 2; j1 = 1
251-
}
252-
else
253-
{
254-
i1 = 0; j1 = 1
255-
}
256-
257-
if n & 4 != 0
258-
{
259-
i2 = 1; j2 = 2
260-
}
261-
else
262-
{
263-
i2 = 1; j2 = 0
264-
}
265-
}
266-
else
267-
{
268-
if n & 2 != 0
269-
{
270-
i1 = 1; j1 = 0
271-
}
272-
else
273-
{
274-
i1 = -1; j1 = 0
275-
}
276-
277-
if n & 4 != 0
278-
{
279-
i2 = 0; j2 = 1
280-
}
281-
else
282-
{
283-
i2 = 0; j2 = -1
284-
}
285-
}
286-
287247
points.append(LatticePoint(u: 0, v: 0))
288248
points.append(LatticePoint(u: 1, v: 1))
289249
points.append(LatticePoint(u: i1, v: j1))

0 commit comments

Comments
 (0)