mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
fix light benchmark
This commit is contained in:
parent
9e08ec7079
commit
732394c5fe
@ -22,6 +22,7 @@ import de.bixilon.minosoft.data.registries.blocks.light.OpaqueProperty
|
|||||||
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.AdvancedBlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.AdvancedBlockState
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||||
|
import de.bixilon.minosoft.data.registries.blocks.state.manager.SimpleStateManager
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.TestBlock
|
import de.bixilon.minosoft.data.registries.blocks.types.TestBlock
|
||||||
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
||||||
@ -109,8 +110,7 @@ object ChunkTestingUtil {
|
|||||||
fun createBlock(name: String, luminance: Int, lightProperties: LightProperties): Block {
|
fun createBlock(name: String, luminance: Int, lightProperties: LightProperties): Block {
|
||||||
val block = TestBlock(minosoft(name), BlockSettings())
|
val block = TestBlock(minosoft(name), BlockSettings())
|
||||||
val state = AdvancedBlockState(block, properties = emptyMap(), collisionShape = AbstractVoxelShape.EMPTY, outlineShape = AbstractVoxelShape.EMPTY, luminance = luminance, lightProperties = lightProperties, solidRenderer = true)
|
val state = AdvancedBlockState(block, properties = emptyMap(), collisionShape = AbstractVoxelShape.EMPTY, outlineShape = AbstractVoxelShape.EMPTY, luminance = luminance, lightProperties = lightProperties, solidRenderer = true)
|
||||||
block::states.javaField!!.forceSet(block, setOf(state))
|
block::states.forceSet(SimpleStateManager(state))
|
||||||
block.states::default.javaField!!.forceSet(block, state)
|
|
||||||
|
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,10 @@ internal class LightBenchmark {
|
|||||||
for (index in 0 until 256) {
|
for (index in 0 until 256) {
|
||||||
highest.unsafeSet(index or (0x0F shl 8), solid)
|
highest.unsafeSet(index or (0x0F shl 8), solid)
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalPlace = 0L
|
var totalPlace = 0L
|
||||||
var totalBreak = 0L
|
var totalBreak = 0L
|
||||||
val benchmark = BenchmarkUtil.benchmark(10000) {
|
val benchmark = BenchmarkUtil.benchmark(100000) {
|
||||||
totalBreak += measureNanoTime { chunk[7, 255, 7] = null }
|
totalBreak += measureNanoTime { chunk[7, 255, 7] = null }
|
||||||
totalPlace += measureNanoTime { chunk[7, 255, 7] = solid }
|
totalPlace += measureNanoTime { chunk[7, 255, 7] = solid }
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ class SectionLight(
|
|||||||
(neighbours[Directions.O_DOWN] ?: chunk.getOrPut(section.sectionHeight - 1, false))?.light?.traceSkyLightIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, nextNeighbourLevel, Directions.DOWN, totalY - 1)
|
(neighbours[Directions.O_DOWN] ?: chunk.getOrPut(section.sectionHeight - 1, false))?.light?.traceSkyLightIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, nextNeighbourLevel, Directions.DOWN, totalY - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (target != Directions.DOWN && target != null && (lightProperties.propagatesLight(Directions.UP))) {
|
if (target != Directions.DOWN && (target != null || lightProperties.propagatesLight(Directions.UP))) {
|
||||||
if (y < ProtocolDefinition.SECTION_MAX_Y) {
|
if (y < ProtocolDefinition.SECTION_MAX_Y) {
|
||||||
traceSkyLightIncrease(x, y + 1, z, nextNeighbourLevel, Directions.UP, totalY + 1)
|
traceSkyLightIncrease(x, y + 1, z, nextNeighbourLevel, Directions.UP, totalY + 1)
|
||||||
} else if (section.sectionHeight < chunk.maxSection) {
|
} else if (section.sectionHeight < chunk.maxSection) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user