mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
fix: water stripes on blocksdrawer
This commit is contained in:
22
src/net/torvald/unsafe/UnsafeInt2D.kt
Normal file
22
src/net/torvald/unsafe/UnsafeInt2D.kt
Normal 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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user