Skip to content

Commit 802bbbe

Browse files
committed
update Swift 4 syntax and integer protocol
1 parent 4d11776 commit 802bbbe

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

sources/noise/cell.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,12 @@ extension _CellNoise3D
301301

302302
// 0b XXX YYY ZZ
303303

304-
let dp:Math.DoubleV3 = ((Double(hash >> 5 ) - 7/2) * 1/8,
305-
(Double(hash >> 2 & 0b0111 ) - 7/2) * 1/8,
306-
(Double(hash << 1 & 0b0111 + ((hash >> 5 ^ hash >> 2) & 1)) - 7/2) * 1/8)
304+
let axes:Math.DoubleV3 = Math.cast_double(( hash >> 5,
305+
hash >> 2 & 0b0111,
306+
hash << 1 & 0b0111 + ((hash >> 5 ^ hash >> 2) & 1)))
307+
let dp:Math.DoubleV3 = ((axes.x - 7.0/2.0) * 1.0/8.0,
308+
(axes.y - 7.0/2.0) * 1.0/8.0,
309+
(axes.z - 7.0/2.0) * 1.0/8.0)
307310

308311
let dv:Math.DoubleV3 = Math.sub(Math.add(Math.cast_double(generating_point), dp), sample_point)
309312
return Math.dot(dv, dv)

sources/noise/compounds.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ extension FBM where Source:TilingNoise
113113
public
114114
init(tiling source:Source, octaves:Int, persistence:Double = 0.5)
115115
{
116-
print("tiling fbm")
117116
// calculate maximum range
118117
let range_inverse:Double
119118
if persistence == 0.5

sources/noise/hash.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct RandomXorshift
129129

130130
init(seed:Int)
131131
{
132-
self.state128 = (1, 0, UInt32(extendingOrTruncating: seed >> UInt32.bitWidth), UInt32(extendingOrTruncating: seed))
132+
self.state128 = (1, 0, UInt32(truncatingIfNeeded: seed >> UInt32.bitWidth), UInt32(truncatingIfNeeded: seed))
133133
}
134134

135135
mutating

tests/noise/tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func write_png(path:String, width:Int, height:Int, pixbytes:UnsafeBufferPointer<
2323

2424
extension UInt8
2525
{
26-
init<T>(clamping value:T) where T:FloatingPoint
26+
init<T>(clamping value:T) where T:BinaryFloatingPoint
2727
{
2828
self.init(Swift.max(0, Swift.min(255, value)))
2929
}

0 commit comments

Comments
 (0)