prep for chunk meshing

This commit is contained in:
2024-09-01 21:16:05 +10:00
parent cb0e7bb232
commit da26773221
11 changed files with 157 additions and 91 deletions

View File

@ -19,6 +19,16 @@ public class World {
self._chunks[position &>> Chunk.shift]?.setBlock(at: position, type: type)
}
func getChunk(id chunkID: SIMD3<Int>) -> Chunk? {
self._chunks[chunkID]
}
public func forEachChunk(_ body: @escaping (_ id: SIMD3<Int>, _ chunk: Chunk) throws -> Void) rethrows {
for i in self._chunks {
try body(i.key, i.value)
}
}
func generate(width: Int, height: Int, depth: Int, seed: UInt64) {
self._generator.reset(seed: seed)
let orig = SIMD3(width, height, depth) / 2