This commit is contained in:
Alex Zenla
2024-09-01 04:17:22 -04:00
parent 64fcebf4e5
commit 09ae09511d
4 changed files with 114 additions and 26 deletions

View File

@ -1,3 +1,5 @@
import simd
public struct Chunk {
public static let shift = 4 // 16
public static let size: Int = 1 << shift
@ -10,7 +12,11 @@ public struct Chunk {
public let origin: SIMD3<Int>
private var blocks: [Block]
static func getID(position: SIMD3<Float>) -> SIMD3<Int> {
SIMD3(floor(position)) &>> Chunk.shift
}
init(position: SIMD3<Int>, blocks: [Block]) {
assert(blocks.count == Self.blockCount)
self.origin = position