mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
split split mix sixty four
This commit is contained in:
@ -3,13 +3,11 @@ struct WorldGenerator {
|
||||
|
||||
public mutating func reset(seed: UInt64) {
|
||||
var random: any RandomProvider
|
||||
let initialState = SplitMix64.createState(seed: seed)
|
||||
#if true
|
||||
random = Xoroshiro128PlusPlus(seed: seed)
|
||||
random = Xoroshiro128PlusPlus(state: initialState)
|
||||
#else
|
||||
//TODO: Fill seed with a hash
|
||||
random = PCG32Random(state: (
|
||||
UInt64(Arc4Random.instance.next()) | UInt64(Arc4Random.instance.next()) << 32,
|
||||
UInt64(Arc4Random.instance.next()) | UInt64(Arc4Random.instance.next()) << 32))
|
||||
random = PCG32Random(seed: initialState)
|
||||
#endif
|
||||
|
||||
self.noise = ImprovedPerlin<Float>(random: &random)
|
||||
@ -38,3 +36,11 @@ struct WorldGenerator {
|
||||
return chunk
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension RandomProvider where Output == UInt64, Self: RandomSeedable, SeedType == UInt64 {
|
||||
static func createState(seed value: UInt64) -> (UInt64, UInt64) {
|
||||
var hash = Self(seed: value)
|
||||
let state = (hash.next(), hash.next())
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user