new lightmap: nice try but didn't work

This commit is contained in:
minjaesong
2020-02-21 03:40:37 +09:00
parent 9d51f419f5
commit 947224c290
6 changed files with 240 additions and 5 deletions

View File

@@ -70,6 +70,21 @@ class Cvec {
set(color)
}
/**
* Get RGBA Element using index, of which:
* - 0: R
* - 1: G
* - 2: B
* - 3: A
*/
fun getElem(index: Int) = when(index) {
0 -> r
1 -> g
2 -> b
3 -> a
else -> throw IndexOutOfBoundsException("Invalid index $index")
}
/** Sets this color to the given color.
*
* @param color the Cvec

View File

@@ -29,6 +29,18 @@ internal class UnsafeCvecArray(val width: Int, val height: Int) {
fun setB(x: Int, y: Int, value: Float) { array.setFloat(toAddr(x, y) + 8, value) }
fun setA(x: Int, y: Int, value: Float) { array.setFloat(toAddr(x, y) + 12, value) }
/**
* @param channel 0 for R, 1 for G, 2 for B, 3 for A
*/
inline fun channelSet(x: Int, y: Int, channel: Int, value: Float) {
array.setFloat(toAddr(x, y) + 4L * channel, value)
}
/**
* @param channel 0 for R, 1 for G, 2 for B, 3 for A
*/
inline fun channelGet(x: Int, y: Int, channel: Int) = array.getFloat(toAddr(x, y) + 4L * channel)
fun max(x: Int, y: Int, other: Cvec) {
setR(x, y, maxOf(getR(x, y), other.r))
setG(x, y, maxOf(getG(x, y), other.g))