mirror of
				https://github.com/GayPizzaSpecifications/voxelotl-engine.git
				synced 2025-11-04 10:59:39 +00:00 
			
		
		
		
	switch permutation type to ubyte
This commit is contained in:
		@ -7,7 +7,7 @@ public protocol CoherentNoiseRandomInit: CoherentNoise {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public protocol CoherentNoiseTableInit: CoherentNoise {
 | 
			
		||||
  init(permutation: [Int16])
 | 
			
		||||
  init(permutation: [UInt8])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public protocol CoherentNoise2D: CoherentNoise {
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,15 @@
 | 
			
		||||
import Foundation
 | 
			
		||||
 | 
			
		||||
public struct ImprovedPerlin<Scalar: BinaryFloatingPoint & SIMDScalar>: 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: RandomProvider>(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>) -> Scalar {
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,16 @@
 | 
			
		||||
import Foundation
 | 
			
		||||
 | 
			
		||||
public struct SimplexNoise<Scalar: BinaryFloatingPoint & SIMDScalar>: 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: RandomProvider>(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 }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user