mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
minor test performance improvements
- ChunkHeightmap is now only calculated if dimension has light (aka. only in light tests) - occlusion culling and light is just updated when dimension has light (world filling) - ...
This commit is contained in:
parent
bd549a1355
commit
9ec4eb8278
@ -91,6 +91,8 @@ object WorldTestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (!dimension.light && !dimension.skyLight) return // no need for occlusion when light is ignored
|
||||
|
||||
if (superUnsafe) {
|
||||
for (x in (start.x shr 4)..(end.x shr 4)) {
|
||||
for (z in (start.z shr 4)..(end.z shr 4)) {
|
||||
@ -107,9 +109,7 @@ object WorldTestUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dimension.light || dimension.skyLight) {
|
||||
recalculateLight(heightmap = true) // yah, might break the result, don't use fill if you want to test light
|
||||
}
|
||||
recalculateLight(heightmap = true) // yah, might break the result, don't use fill if you want to test light
|
||||
}
|
||||
|
||||
private val DATA = SectionDataProvider::class.java.getDeclaredField("data").apply { isAccessible = true }
|
||||
|
@ -34,7 +34,7 @@ abstract class ChunkHeightmap(protected val chunk: Chunk) : Heightmap {
|
||||
val maxY = (chunk.maxSection + 1) * ProtocolDefinition.SECTION_HEIGHT_Y
|
||||
|
||||
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
||||
for (x in 0 until ProtocolDefinition.SECTION_WIDTH_X) {
|
||||
for (x in 0 until ProtocolDefinition.SECTION_WIDTH_X) {
|
||||
trace(x, maxY, z, false)
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
||||
object ChunkLightUtil {
|
||||
|
||||
fun DimensionProperties.hasSkyLight(): Boolean {
|
||||
return this.skyLight || this.effects.skyLight
|
||||
return this.light && this.skyLight
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class ChunkSkyLight(val light: ChunkLight) {
|
||||
private fun floodFill() {
|
||||
val neighbours = this.chunk.neighbours.get() ?: return
|
||||
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
||||
for (x in 0 until ProtocolDefinition.SECTION_WIDTH_X) {
|
||||
for (x in 0 until ProtocolDefinition.SECTION_WIDTH_X) {
|
||||
floodFill(neighbours, x, z)
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class SectionLight(
|
||||
|
||||
private fun propagateX(baseY: Int, neighbours: Array<ChunkSection?>) {
|
||||
for (y in 0 until ProtocolDefinition.SECTION_HEIGHT_Y) {
|
||||
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
||||
for (z in 0 until ProtocolDefinition.SECTION_WIDTH_Z) {
|
||||
val totalY = baseY + y
|
||||
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) }
|
||||
|
@ -135,7 +135,8 @@ class ChunkManager(val world: World, chunkCapacity: Int = 0, prototypeCapacity:
|
||||
size.onCreate(chunk.chunkPosition)
|
||||
world.view.updateServerDistance()
|
||||
|
||||
val updates = hashSetOf<AbstractWorldUpdate>(ChunkCreateUpdate(chunk.chunkPosition, chunk))
|
||||
val updates = HashSet<AbstractWorldUpdate>(9, 1.0f)
|
||||
updates += ChunkCreateUpdate(chunk.chunkPosition, chunk)
|
||||
|
||||
for (index in 0 until ChunkNeighbours.COUNT) {
|
||||
val offset = ChunkNeighbours.OFFSETS[index]
|
||||
|
Loading…
x
Reference in New Issue
Block a user