mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 08:36:07 +09:00
unsafe array on lightmaprenderer: could this be possible?
This commit is contained in:
@@ -5,7 +5,10 @@ import net.torvald.terrarum.AppLoader.printdbg
|
|||||||
import sun.misc.Unsafe
|
import sun.misc.Unsafe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-17.
|
* Original version Created by minjaesong on 2016-01-17.
|
||||||
|
* Unsafe version Created by minjaesong on 2019-06-08.
|
||||||
|
*
|
||||||
|
* Note to self: refrain from using shorts--just do away with two bytes: different system have different endianness
|
||||||
*/
|
*/
|
||||||
open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ object LightmapRenderer {
|
|||||||
val ypos = y - for_y_start + overscan_open
|
val ypos = y - for_y_start + overscan_open
|
||||||
val xpos = x - for_x_start + overscan_open
|
val xpos = x - for_x_start + overscan_open
|
||||||
|
|
||||||
|
// TODO as you can see above, we're already doing a boundary check; try using unsafe here?
|
||||||
return lightmap[ypos][xpos]
|
return lightmap[ypos][xpos]
|
||||||
//return lightmap[ypos * LIGHTMAP_WIDTH + xpos]
|
//return lightmap[ypos * LIGHTMAP_WIDTH + xpos]
|
||||||
}
|
}
|
||||||
@@ -174,6 +175,7 @@ object LightmapRenderer {
|
|||||||
val ypos = y - for_y_start + overscan_open
|
val ypos = y - for_y_start + overscan_open
|
||||||
val xpos = x - for_x_start + overscan_open
|
val xpos = x - for_x_start + overscan_open
|
||||||
|
|
||||||
|
// TODO as you can see above, we're already doing a boundary check; try using unsafe here?
|
||||||
lightmap[ypos][xpos] = applyFun.invoke(list[ypos][xpos], colour)
|
lightmap[ypos][xpos] = applyFun.invoke(list[ypos][xpos], colour)
|
||||||
//list[ypos * LIGHTMAP_WIDTH + xpos] = applyFun.invoke(list[ypos * LIGHTMAP_WIDTH + xpos], colour)
|
//list[ypos * LIGHTMAP_WIDTH + xpos] = applyFun.invoke(list[ypos * LIGHTMAP_WIDTH + xpos], colour)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user