Skip to content

Commit a13d4c8

Browse files
committed
clean up
1 parent a7a1444 commit a13d4c8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

sources/noise/cell.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ struct CellNoise3D:Noise
270270

271271
// Same idea as with the 2D points, except in 3 dimensions
272272

273-
// near - quadrant ---- near - quadrant.y
274-
// | | |
275-
// |----+----|
276-
// | | * |
277-
// near - quadrant.x -- near quadrant →
273+
// near - quadrant.xy ———— near - quadrant.y
274+
// | | |
275+
// |----+----|
276+
// | | * |
277+
// near - quadrant.x ————— near quadrant →
278278
// ↓
279279

280280
let quadrant:IntV3 = (offset.x > 0.5 ? 1 : -1, offset.y > 0.5 ? 1 : -1, offset.z > 0.5 ? 1 : -1),
@@ -284,9 +284,9 @@ struct CellNoise3D:Noise
284284
abs(offset.y - Double((quadrant.b + 1) >> 1)),
285285
abs(offset.z - Double((quadrant.c + 1) >> 1)))
286286

287-
var r2_min:Double = self.distance(from: sample, generating_point: near)
287+
var r2:Double = self.distance(from: sample, generating_point: near)
288288

289-
let kernel:[(r:Double, cell_offsets:[(Int, Int, Int)])] =
289+
let kernel:[(r2:Double, cell_offsets:[(Int, Int, Int)])] =
290290
[
291291
(0.0 , [/*(0, 0, 0), */(-1, 0, 0), (0, -1, 0), (-1, -1, 0), (0, 0, -1), (-1, 0, -1), (0, -1, -1), (-1, -1, -1)]),
292292
(0.25, [(0, 0, 1), (-1, 0, 1), (0, -1, 1), (-1, -1, 1), (0, 1, 0), (-1, 1, 0), (1, 0, 0), (1, -1, 0),
@@ -306,9 +306,10 @@ struct CellNoise3D:Noise
306306
(2.75, [(1, 1, 2), (1, 2, 1), (2, 1, 1)])
307307
]
308308

309-
for (kernel_radius, cell_offsets):(r:Double, cell_offsets:[(Int, Int, Int)]) in kernel
309+
for (kernel_radius2, cell_offsets):(r2:Double, cell_offsets:[(Int, Int, Int)]) in kernel
310310
{
311-
if r2_min < kernel_radius
311+
guard kernel_radius2 < r2
312+
else
312313
{
313314
break // EARLY EXIT
314315
}
@@ -339,7 +340,7 @@ struct CellNoise3D:Noise
339340
cell_distance2 += dz*dz
340341
}
341342

342-
guard cell_distance2 < r2_min
343+
guard cell_distance2 < r2
343344
else
344345
{
345346
continue
@@ -348,17 +349,16 @@ struct CellNoise3D:Noise
348349
let generating_point:IntV3 = (near.a + quadrant.a*cell_offset.a,
349350
near.b + quadrant.b*cell_offset.b,
350351
near.c + quadrant.c*cell_offset.c)
351-
let r2:Double = self.distance(from: sample, generating_point: generating_point)
352-
r2_min = min(r2, r2_min)
352+
r2 = min(r2, self.distance(from: sample, generating_point: generating_point))
353353
}
354354
}
355355

356-
return self.amplitude * r2_min
356+
return self.amplitude * r2
357357
}
358358

359359
public
360360
func evaluate(_ x:Double, _ y:Double, _ z:Double, _:Double) -> Double
361361
{
362-
return self.evaluate(x, y)
362+
return self.evaluate(x, y, z)
363363
}
364364
}

0 commit comments

Comments
 (0)