mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
light: fix bugs and improve performance when propagating light from neighbours
This commit is contained in:
parent
6c7915dcaf
commit
e981d0718a
@ -255,10 +255,12 @@ class SectionLight(
|
||||
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
||||
val totalY = baseY + y
|
||||
neighbours[Directions.O_WEST]?.light?.get(ProtocolDefinition.SECTION_MAX_Z, y, z)?.toInt()?.let {
|
||||
if (it == 0) return@let
|
||||
traceIncrease(0, y, z, (it and BLOCK_LIGHT_MASK).dec(), Directions.EAST)
|
||||
traceSkylight(0, y, z, (it and SKY_LIGHT_MASK shr 4).dec(), Directions.EAST, totalY)
|
||||
}
|
||||
neighbours[Directions.O_EAST]?.light?.get(0, y, z)?.toInt()?.dec()?.let {
|
||||
neighbours[Directions.O_EAST]?.light?.get(0, y, z)?.toInt()?.let {
|
||||
if (it == 0) return@let
|
||||
traceIncrease(ProtocolDefinition.SECTION_MAX_X, y, z, (it and BLOCK_LIGHT_MASK).dec(), Directions.WEST)
|
||||
traceSkylight(ProtocolDefinition.SECTION_MAX_X, y, z, (it and SKY_LIGHT_MASK shr 4).dec(), Directions.WEST, totalY)
|
||||
}
|
||||
@ -270,10 +272,12 @@ class SectionLight(
|
||||
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
||||
val totalY = baseY + y
|
||||
neighbours[Directions.O_NORTH]?.light?.get(x, y, ProtocolDefinition.SECTION_MAX_Z)?.toInt()?.let {
|
||||
if (it == 0) return@let
|
||||
traceIncrease(x, y, 0, (it and BLOCK_LIGHT_MASK).dec(), Directions.SOUTH)
|
||||
traceSkylight(x, y, 0, (it and SKY_LIGHT_MASK shr 4).dec(), Directions.SOUTH, totalY)
|
||||
}
|
||||
neighbours[Directions.O_SOUTH]?.light?.get(x, y, 0)?.toInt()?.let {
|
||||
if (it == 0) return@let
|
||||
traceIncrease(x, y, ProtocolDefinition.SECTION_MAX_Z, (it and BLOCK_LIGHT_MASK).dec(), Directions.NORTH)
|
||||
traceSkylight(x, y, ProtocolDefinition.SECTION_MAX_Z, (it and SKY_LIGHT_MASK shr 4).dec(), Directions.NORTH, totalY)
|
||||
}
|
||||
@ -283,10 +287,12 @@ class SectionLight(
|
||||
private fun propagateY(neighbours: Array<ChunkSection?>, x: Int, baseY: Int) {
|
||||
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
||||
neighbours[Directions.O_DOWN]?.light?.get(x, ProtocolDefinition.SECTION_MAX_Y, z)?.toInt()?.let {
|
||||
if (it == 0) return@let
|
||||
traceIncrease(x, 0, z, (it and BLOCK_LIGHT_MASK).dec(), Directions.UP)
|
||||
traceSkylight(x, 0, z, (it and SKY_LIGHT_MASK shr 4).dec(), Directions.UP, baseY + 0) // ToDo: Is that possible?
|
||||
}
|
||||
neighbours[Directions.O_UP]?.light?.get(x, 0, z)?.toInt()?.let {
|
||||
if (it == 0) return@let
|
||||
traceIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, (it and BLOCK_LIGHT_MASK).dec(), Directions.DOWN)
|
||||
traceSkylight(x, ProtocolDefinition.SECTION_MAX_Y, z, (it and SKY_LIGHT_MASK shr 4).dec(), Directions.DOWN, baseY + ProtocolDefinition.SECTION_MAX_Y)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user