Skip to content

Commit e96e11e

Browse files
committed
make comments consistent
1 parent e0614a4 commit e96e11e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sources/noise/cell.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ struct CellNoise3D:Noise
253253

254254
var r2:Double = self.distance(from: sample, generating_point: near)
255255

256+
// the following unrolled code is not actually necessary — the loop at the
257+
// bottom of the function is capable of handling all cases, but unrolling
258+
// it partially results in an enormous performance gain, about a factor
259+
// of 7 over the pure loop version.
256260
@inline(__always)
257261
func test(generating_point:IntV3, dx:Double = 0, dy:Double = 0, dz:Double = 0)
258262
{
@@ -274,7 +278,7 @@ struct CellNoise3D:Noise
274278

275279
test(generating_point: far, dx: nearpoint_disp.x - 0.5, dy: nearpoint_disp.y - 0.5, dz: nearpoint_disp.z - 0.5)
276280

277-
// Testing shows about 47.85% of samples are eliminated by here
281+
// EARLY EXIT: Testing shows about 47.85% of samples are eliminated by here
278282
// (0.25, [(1, 0, 0), ( 0, 1, 0), ( 0, 0, 1),
279283
// (0, -1, 1), ( 0, 1, -1), ( 1, 0, -1), (-1, 0, 1), (-1, 1, 0), (1, -1, 0),
280284
// (1, -1, -1), (-1, 1, -1), (-1, -1, 1)])
@@ -300,7 +304,7 @@ struct CellNoise3D:Noise
300304
test(generating_point: (far.a, inner.b, far.c), dx: nearpoint_disp.x - 0.5, dy: nearpoint_disp.y + 0.5, dz: nearpoint_disp.z - 0.5)
301305
test(generating_point: (far.a, far.b, inner.c), dx: nearpoint_disp.x - 0.5, dy: nearpoint_disp.y - 0.5, dz: nearpoint_disp.z + 0.5)
302306

303-
// Testing shows about 88.60% of samples are eliminated by here
307+
// EARLY EXIT: Testing shows about 88.60% of samples are eliminated by here
304308
// (0.5 , [(0, 1, 1), (1, 0, 1), (1, 1, 0), (-1, 1, 1), (1, -1, 1), (1, 1, -1)])
305309
guard r2 > 0.5
306310
else
@@ -316,7 +320,7 @@ struct CellNoise3D:Noise
316320
test(generating_point: (inner.a, far.b, inner.c), dx: nearpoint_disp.x + 0.5, dy: nearpoint_disp.y - 0.5, dz: nearpoint_disp.z + 0.5)
317321
test(generating_point: (inner.a, inner.b, far.c), dx: nearpoint_disp.x + 0.5, dy: nearpoint_disp.y + 0.5, dz: nearpoint_disp.z - 0.5)
318322

319-
// Testing shows about 98.26% of samples are eliminated by here
323+
// EARLY EXIT: Testing shows about 98.26% of samples are eliminated by here
320324
// (0.75, [(1, 1, 1)])
321325
guard r2 > 0.75
322326
else
@@ -353,10 +357,11 @@ struct CellNoise3D:Noise
353357

354358
for (kernel_radius2, cell_offsets):(r2:Double, cell_offsets:[(Int, Int, Int)]) in kernel
355359
{
360+
// EARLY EXIT
356361
guard kernel_radius2 < r2
357362
else
358363
{
359-
break // EARLY EXIT
364+
break
360365
}
361366

362367
for cell_offset:IntV3 in cell_offsets

0 commit comments

Comments
 (0)