Skip to content

Commit f0fb959

Browse files
committed
rename distance to distance 2 to reflect that it’s a squared quantity
1 parent 5773f47 commit f0fb959

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sources/noise/cell.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct CellNoise2D:Noise
1515
}
1616

1717
private
18-
func distance(from sample_point:Math.DoubleV2, generating_point:Math.IntV2) -> Double
18+
func distance2(from sample_point:Math.DoubleV2, generating_point:Math.IntV2) -> Double
1919
{
2020
let hash:Int = self.permutation_table.hash(generating_point)
2121
// hash is within 0 ... 255, take it to 0 ... 0.5
@@ -80,14 +80,14 @@ struct CellNoise2D:Noise
8080
let nearpoint_disp:Math.DoubleV2 = (abs(sample_rel.x - Double((quadrant.a + 1) >> 1)),
8181
abs(sample_rel.y - Double((quadrant.b + 1) >> 1)))
8282

83-
var r2:Double = self.distance(from: sample, generating_point: near)
83+
var r2:Double = self.distance2(from: sample, generating_point: near)
8484

8585
@inline(__always)
8686
func _inspect(generating_point:Math.IntV2, dx:Double = 0, dy:Double = 0)
8787
{
8888
if dx*dx + dy*dy < r2
8989
{
90-
r2 = min(r2, self.distance(from: sample, generating_point: generating_point))
90+
r2 = min(r2, self.distance2(from: sample, generating_point: generating_point))
9191
}
9292
}
9393

@@ -192,7 +192,7 @@ struct CellNoise3D:Noise
192192
}
193193

194194
private
195-
func distance(from sample_point:Math.DoubleV3, generating_point:Math.IntV3) -> Double
195+
func distance2(from sample_point:Math.DoubleV3, generating_point:Math.IntV3) -> Double
196196
{
197197
let hash:Int = self.permutation_table.hash(generating_point)
198198
// hash is within 0 ... 255, take it to 0 ... 0.5
@@ -248,7 +248,7 @@ struct CellNoise3D:Noise
248248
abs(sample_rel.y - Double((quadrant.b + 1) >> 1)),
249249
abs(sample_rel.z - Double((quadrant.c + 1) >> 1)))
250250

251-
var r2:Double = self.distance(from: sample, generating_point: near)
251+
var r2:Double = self.distance2(from: sample, generating_point: near)
252252

253253
@inline(__always)
254254
func _inspect_cell(offset:Math.IntV3)
@@ -286,7 +286,7 @@ struct CellNoise3D:Noise
286286
let generating_point:Math.IntV3 = (near.a + quadrant.a*offset.a,
287287
near.b + quadrant.b*offset.b,
288288
near.c + quadrant.c*offset.c)
289-
r2 = min(r2, self.distance(from: sample, generating_point: generating_point))
289+
r2 = min(r2, self.distance2(from: sample, generating_point: generating_point))
290290
}
291291

292292
// check each cell group, exiting early if we are guaranteed to have found

0 commit comments

Comments
 (0)