mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
light: fix neighbour propagation
This commit is contained in:
parent
8887160835
commit
a68cf346b7
@ -210,7 +210,6 @@ class SectionLight(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun calculate() {
|
fun calculate() {
|
||||||
// ToDo: skylight
|
|
||||||
update = true
|
update = true
|
||||||
val blocks = section.blocks
|
val blocks = section.blocks
|
||||||
|
|
||||||
@ -261,12 +260,12 @@ class SectionLight(
|
|||||||
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
||||||
val totalY = baseY + y
|
val totalY = baseY + y
|
||||||
neighbours[Directions.O_WEST]?.light?.get(ProtocolDefinition.SECTION_MAX_Z, y, z)?.toInt()?.let { light ->
|
neighbours[Directions.O_WEST]?.light?.get(ProtocolDefinition.SECTION_MAX_Z, y, z)?.toInt()?.let { light ->
|
||||||
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(0, y, z, it - 1, Directions.EAST) }
|
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(0, y, z, it - 1, Directions.WEST) }
|
||||||
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(0, y, z, it - 1, Directions.EAST, totalY) }
|
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(0, y, z, it - 1, Directions.WEST, totalY) }
|
||||||
}
|
}
|
||||||
neighbours[Directions.O_EAST]?.light?.get(0, y, z)?.toInt()?.let { light ->
|
neighbours[Directions.O_EAST]?.light?.get(0, y, z)?.toInt()?.let { light ->
|
||||||
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(ProtocolDefinition.SECTION_MAX_X, y, z, it - 1, Directions.WEST) }
|
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(ProtocolDefinition.SECTION_MAX_X, y, z, it - 1, Directions.EAST) }
|
||||||
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(ProtocolDefinition.SECTION_MAX_X, y, z, it - 1, Directions.WEST, totalY) }
|
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(ProtocolDefinition.SECTION_MAX_X, y, z, it - 1, Directions.EAST, totalY) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,12 +275,12 @@ class SectionLight(
|
|||||||
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
||||||
val totalY = baseY + y
|
val totalY = baseY + y
|
||||||
neighbours[Directions.O_NORTH]?.light?.get(x, y, ProtocolDefinition.SECTION_MAX_Z)?.toInt()?.let { light ->
|
neighbours[Directions.O_NORTH]?.light?.get(x, y, ProtocolDefinition.SECTION_MAX_Z)?.toInt()?.let { light ->
|
||||||
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, y, 0, it - 1, Directions.SOUTH) }
|
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, y, 0, it - 1, Directions.NORTH) }
|
||||||
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, y, 0, it - 1, Directions.SOUTH, totalY) }
|
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, y, 0, it - 1, Directions.NORTH, totalY) }
|
||||||
}
|
}
|
||||||
neighbours[Directions.O_SOUTH]?.light?.get(x, y, 0)?.toInt()?.let { light ->
|
neighbours[Directions.O_SOUTH]?.light?.get(x, y, 0)?.toInt()?.let { light ->
|
||||||
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, y, ProtocolDefinition.SECTION_MAX_Z, it - 1, Directions.NORTH) }
|
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, y, ProtocolDefinition.SECTION_MAX_Z, it - 1, Directions.SOUTH) }
|
||||||
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, y, ProtocolDefinition.SECTION_MAX_Z, it - 1, Directions.NORTH, totalY) }
|
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, y, ProtocolDefinition.SECTION_MAX_Z, it - 1, Directions.SOUTH, totalY) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,12 +288,12 @@ class SectionLight(
|
|||||||
private fun propagateY(neighbours: Array<ChunkSection?>, x: Int, baseY: Int) {
|
private fun propagateY(neighbours: Array<ChunkSection?>, x: Int, baseY: Int) {
|
||||||
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
||||||
neighbours[Directions.O_DOWN]?.light?.get(x, ProtocolDefinition.SECTION_MAX_Y, z)?.toInt()?.let { light ->
|
neighbours[Directions.O_DOWN]?.light?.get(x, ProtocolDefinition.SECTION_MAX_Y, z)?.toInt()?.let { light ->
|
||||||
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, 0, z, it - 1, Directions.UP) }
|
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, 0, z, it - 1, Directions.DOWN) }
|
||||||
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, 0, z, it - 1, Directions.UP, baseY + 0) } // ToDo: Is that possible?
|
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, 0, z, it - 1, Directions.DOWN, baseY + 0) } // ToDo: Is that possible?
|
||||||
}
|
}
|
||||||
neighbours[Directions.O_UP]?.light?.get(x, 0, z)?.toInt()?.let { light ->
|
neighbours[Directions.O_UP]?.light?.get(x, 0, z)?.toInt()?.let { light ->
|
||||||
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, it - 1, Directions.DOWN) }
|
(light and BLOCK_LIGHT_MASK).let { if (it > 1) traceBlockIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, it - 1, Directions.UP) }
|
||||||
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, it - 1, Directions.DOWN, baseY + ProtocolDefinition.SECTION_MAX_Y) }
|
(light and SKY_LIGHT_MASK shr 4).let { if (it > 1) traceSkylightIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, it - 1, Directions.UP, baseY + ProtocolDefinition.SECTION_MAX_Y) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user