mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
new lightmap: nice try but didn't work
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user