fix: water stripes on blocksdrawer

This commit is contained in:
minjaesong
2024-07-22 14:23:58 +09:00
parent 91e25da54f
commit 1fddb5f0da
2 changed files with 82 additions and 31 deletions

View File

@@ -0,0 +1,22 @@
package net.torvald.unsafe
/**
* Created by minjaesong on 2024-07-22.
*/
class UnsafeInt2D(width: Int, height: Int) {
val width = width.toLong()
val height = height.toLong()
private val ptr = UnsafeHelper.allocate(4L * width * height)
private inline fun toIndex(y: Int, x: Int) = width * y + x
operator fun set(y: Int, x: Int, value: Int) = ptr.setInt(toIndex(y, x), value)
operator fun get(y: Int, x: Int) = ptr.getInt(toIndex(y, x))
fun destroy() = ptr.destroy()
val destroyed: Boolean
get() = ptr.destroyed
}