turn the ChunkID type alias into a real type

This commit is contained in:
2024-09-08 03:47:26 +10:00
parent 76b61c49ae
commit b804030594
9 changed files with 78 additions and 39 deletions

View File

@ -15,7 +15,7 @@ struct StandardWorldGenerator: WorldGenerator {
self.colorNoise = .init(random: &random, octaves: 15, frequency: 0.006667, amplitude: 3)
}
public func makeChunk(id chunkID: SIMD3<Int>) -> Chunk {
public func makeChunk(id chunkID: ChunkID) -> Chunk {
let blockFunc = { (height: Float, position: SIMD3<Float>) -> BlockType in
#if true
let value = height + self.terrainNoise.get(position * SIMD3(1, 2, 1))
@ -37,7 +37,7 @@ struct StandardWorldGenerator: WorldGenerator {
saturation: 0.47, value: 0.9).linear)
}
let chunkOrigin = chunkID &<< Chunk.shift
let chunkOrigin = chunkID.getPosition()
var chunk = Chunk(position: chunkOrigin)
for z in 0..<Chunk.size {
for x in 0..<Chunk.size {

View File

@ -10,8 +10,8 @@ struct TerrorTowerGenerator: WorldGenerator {
self.noise2 = LayeredNoise(random: &random, octaves: 3, frequency: 0.1)
}
public func makeChunk(id chunkID: SIMD3<Int>) -> Chunk {
let chunkOrigin = chunkID &<< Chunk.shift
public func makeChunk(id chunkID: ChunkID) -> Chunk {
let chunkOrigin = chunkID.getPosition()
var chunk = Chunk(position: chunkOrigin)
chunk.fill(allBy: { position in
let fpos = SIMD3<Float>(chunkOrigin &+ position)

View File

@ -1,6 +1,6 @@
public protocol WorldGenerator {
mutating func reset(seed: UInt64)
func makeChunk(id: SIMD3<Int>) -> Chunk
func makeChunk(id: ChunkID) -> Chunk
}
internal extension RandomProvider where Output == UInt64, Self: RandomSeedable, SeedType == UInt64 {