inline chunk section index functions

* Performance improvement
This commit is contained in:
Bixilon 2022-09-16 20:43:57 +02:00
parent 440c00d29a
commit e47e60191d
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -104,13 +104,13 @@ class ChunkSection(
companion object { companion object {
val Vec3i.index: Int inline val Vec3i.index: Int
get() = getIndex(x, y, z) get() = getIndex(x, y, z)
val Int.indexPosition: Vec3i inline val Int.indexPosition: Vec3i
get() = Vec3i(this and 0x0F, (this shr 8) and 0x0F, (this shr 4) and 0x0F) get() = Vec3i(this and 0x0F, (this shr 8) and 0x0F, (this shr 4) and 0x0F)
fun getIndex(x: Int, y: Int, z: Int): Int { inline fun getIndex(x: Int, y: Int, z: Int): Int {
return y shl 8 or (z shl 4) or x return y shl 8 or (z shl 4) or x
} }
} }