From b6085c8f1cf6a8f60906a2a9e0f6c84dfbc010ad Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 9 Sep 2024 04:11:26 +1000 Subject: [PATCH] switch permutation type to ubyte --- Sources/Voxelotl/Noise/CoherentNoise.swift | 2 +- Sources/Voxelotl/Noise/LayeredNoise.swift | 2 +- Sources/Voxelotl/Noise/PerlinNoiseGenerator.swift | 6 +++--- Sources/Voxelotl/Noise/SimplexNoise.swift | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/Voxelotl/Noise/CoherentNoise.swift b/Sources/Voxelotl/Noise/CoherentNoise.swift index 217a12c..fe27cf4 100644 --- a/Sources/Voxelotl/Noise/CoherentNoise.swift +++ b/Sources/Voxelotl/Noise/CoherentNoise.swift @@ -7,7 +7,7 @@ public protocol CoherentNoiseRandomInit: CoherentNoise { } public protocol CoherentNoiseTableInit: CoherentNoise { - init(permutation: [Int16]) + init(permutation: [UInt8]) } public protocol CoherentNoise2D: CoherentNoise { diff --git a/Sources/Voxelotl/Noise/LayeredNoise.swift b/Sources/Voxelotl/Noise/LayeredNoise.swift index 5ddee24..19300ab 100644 --- a/Sources/Voxelotl/Noise/LayeredNoise.swift +++ b/Sources/Voxelotl/Noise/LayeredNoise.swift @@ -20,7 +20,7 @@ public extension LayeredNoise where Generator: CoherentNoiseRandomInit { } public extension LayeredNoise where Generator: CoherentNoiseTableInit { - init(permutation table: [Int16], octaves: Int, frequency: Scalar, amplitude: Scalar = 1) { + init(permutation table: [UInt8], octaves: Int, frequency: Scalar, amplitude: Scalar = 1) { self.octaves = octaves self.frequency = frequency self.amplitude = amplitude diff --git a/Sources/Voxelotl/Noise/PerlinNoiseGenerator.swift b/Sources/Voxelotl/Noise/PerlinNoiseGenerator.swift index 511d649..cc86857 100644 --- a/Sources/Voxelotl/Noise/PerlinNoiseGenerator.swift +++ b/Sources/Voxelotl/Noise/PerlinNoiseGenerator.swift @@ -1,15 +1,15 @@ import Foundation public struct ImprovedPerlin: CoherentNoise2D, CoherentNoise3D, CoherentNoiseRandomInit, CoherentNoiseTableInit { - private let p: [Int16] + private let p: [UInt8] - public init(permutation: [Int16]) { + public init(permutation: [UInt8]) { assert(permutation.count == 0x100) self.p = permutation } public init(random: inout Random) { - self.p = (0..<0x100).map { Int16($0) }.shuffled(using: &random) + self.p = (0..<0x100).map { UInt8($0) }.shuffled(using: &random) } public func get(_ point: SIMD2) -> Scalar { diff --git a/Sources/Voxelotl/Noise/SimplexNoise.swift b/Sources/Voxelotl/Noise/SimplexNoise.swift index 8708bbf..0c22611 100644 --- a/Sources/Voxelotl/Noise/SimplexNoise.swift +++ b/Sources/Voxelotl/Noise/SimplexNoise.swift @@ -1,16 +1,16 @@ import Foundation public struct SimplexNoise: CoherentNoise2D, CoherentNoise3D, CoherentNoise4D, CoherentNoiseRandomInit, CoherentNoiseTableInit { - private let p: [Int16], pMod12: [Int16] + private let p: [UInt8], pMod12: [UInt8] - public init(permutation: [Int16]) { + public init(permutation: [UInt8]) { assert(permutation.count == 0x100) self.p = permutation self.pMod12 = self.p.map { $0 % 12 } } public init(random: inout Random) { - self.p = (0..<0x100).map { Int16($0) }.shuffled(using: &random) + self.p = (0..<0x100).map { UInt8($0) }.shuffled(using: &random) self.pMod12 = self.p.map { $0 % 12 } }