light engine: micro optimisations…

This commit is contained in:
Bixilon 2022-09-25 22:44:32 +02:00
parent 211dcf84f4
commit 47ccaa0613
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 7 additions and 4 deletions

View File

@ -533,7 +533,7 @@ class Chunk(
if (x < ProtocolDefinition.SECTION_MAX_X) { if (x < ProtocolDefinition.SECTION_MAX_X) {
skylightHeightmap[heightmapIndex + 1] skylightHeightmap[heightmapIndex + 1]
} else { } else {
neighbours[ChunkNeighbours.WEST].skylightHeightmap[((z shl 4) or 0)] neighbours[ChunkNeighbours.WEST].skylightHeightmap[(z shl 4) or 0]
}, },
if (z > 0) { if (z > 0) {
@ -569,7 +569,7 @@ class Chunk(
} }
} }
fun getMaxHeight(x: Int, z: Int): Int { inline fun getMaxHeight(x: Int, z: Int): Int {
return skylightHeightmap[(z shl 4) or x] return skylightHeightmap[(z shl 4) or x]
} }
} }

View File

@ -264,11 +264,14 @@ class SectionLight(
return return
} }
val lightProperties = section.blocks.unsafeGet(index)?.lightProperties ?: TransparentProperty var lightProperties = section.blocks.unsafeGet(index)?.lightProperties
if (!lightProperties.propagatesLight) { if (lightProperties == null) {
lightProperties = TransparentProperty
} else if (!lightProperties.propagatesLight) {
return return
} }
this.light[index] = ((currentLight and BLOCK_LIGHT_MASK) or (nextLevel shl 4)).toByte() this.light[index] = ((currentLight and BLOCK_LIGHT_MASK) or (nextLevel shl 4)).toByte()
val neighbours = this.section.neighbours ?: return val neighbours = this.section.neighbours ?: return