improved perlin basic blockgen

This commit is contained in:
2024-08-23 16:55:59 +10:00
parent efd9905f5b
commit 9ef60faa86
6 changed files with 105 additions and 11 deletions

View File

@ -43,9 +43,15 @@ public struct Chunk {
blocks[position.x + position.y * Self.yStride + position.z * Self.zStride].type = type
}
mutating func fill(allBy calculation: () -> BlockType) {
blocks.indices.forEach { i in
blocks[i].type = calculation()
mutating func fill(allBy calculation: (_ position: SIMD3<Int>) -> BlockType) {
var i = 0
for x in 0..<Self.chunkSize {
for y in 0..<Self.chunkSize {
for z in 0..<Self.chunkSize {
blocks[i].type = calculation(SIMD3(x, y, z))
i += 1
}
}
}
}