Remove technical limitation of ILayeredRenderer

This commit is contained in:
DBotThePony 2022-09-08 21:32:56 +07:00
parent 32c2932a6a
commit 3c0bd56b0a
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 10 additions and 10 deletions

View File

@ -78,8 +78,8 @@ fun main() {
reader.skipBytes(1) // Foreground hue shift
reader.skipBytes(1) // Foreground color variant
val modifier = reader.readShort()
val getModifier = Starbound.tileModifiersByIDAccess[modifier.toInt()]
val modifier = reader.readUnsignedShort()
val getModifier = Starbound.tileModifiersByIDAccess[modifier]
if (getModifier != null && getMat != null) {
chunk.foreground[x, y]?.modifier = getModifier
@ -98,8 +98,8 @@ fun main() {
reader.skipBytes(1) // Background hue shift
reader.skipBytes(1) // Background color variant
val modifier2 = reader.readShort()
val getModifier2 = Starbound.tileModifiersByIDAccess[modifier2.toInt()]
val modifier2 = reader.readUnsignedShort()
val getModifier2 = Starbound.tileModifiersByIDAccess[modifier2]
if (getModifier2 != null && getMat2 != null) {
chunk.background[x, y]?.modifier = getModifier2

View File

@ -252,7 +252,7 @@ class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk<ClientWorld, Client
override fun renderLayerFromStack(zPos: Int, stack: Matrix4fStack): Int {
if (layerQueue.isEmpty())
return -1
return Int.MIN_VALUE
stack.push().translateWithMultiplication(x = origin.x * CHUNK_SIZEf, y = origin.y * CHUNK_SIZEf)
var pair = layerQueue.last()
@ -264,7 +264,7 @@ class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk<ClientWorld, Client
if (layerQueue.isEmpty()) {
stack.pop()
return -1
return Int.MIN_VALUE
}
pair = layerQueue.last()
@ -276,7 +276,7 @@ class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk<ClientWorld, Client
override fun bottomMostZLevel(): Int {
if (layerQueue.isEmpty()) {
return -1
return Int.MIN_VALUE
}
return layerQueue.last().second

View File

@ -19,7 +19,7 @@ interface ILayeredRenderer {
*
* Возвращается zNew следующего слоя (такой, что [zPos] > zNew).
*
* Если следующего слоя нет, вернуть -1, и данный объект
* Если следующего слоя нет, вернуть [Int.MIN_VALUE], и данный объект
* будет считаться отрисованным.
*/
fun renderLayerFromStack(zPos: Int, stack: Matrix4fStack): Int
@ -27,7 +27,7 @@ interface ILayeredRenderer {
/**
* Возвращает наибольшее zPos в данной стопке.
*
* Если стопка пуста, то необходимо вернуть -1.
* Если стопка пуста, то необходимо вернуть [Int.MIN_VALUE].
*
* В зависимости от сцены, которую необходимо отрисовать,
* [renderLayerFromStack] может быть вызван сразу с этим же значением,
@ -62,7 +62,7 @@ fun renderLayeredList(transform: Matrix4fStack, potentialRenderers: List<ILayere
renderCalls++
if (newLevel <= -1) {
if (newLevel == Int.MIN_VALUE) {
renderers.removeAt(i)
} else {
newBottom = newBottom.coerceAtLeast(newLevel)