mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
fix empty chunk data handling, improve multithreading in WorldRenderer
This commit is contained in:
parent
4377b9e2ae
commit
831fd25444
@ -35,10 +35,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.phases.TransparentDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.chunkPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.sectionHeight
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.events.BlockSetEvent
|
||||
import de.bixilon.minosoft.modding.event.events.ChunkDataChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.ChunkUnloadEvent
|
||||
import de.bixilon.minosoft.modding.event.events.MassBlockSetEvent
|
||||
import de.bixilon.minosoft.modding.event.events.*
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.synchronizedMapOf
|
||||
@ -111,6 +108,7 @@ class WorldRenderer(
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<FrustumChangeEvent> { onFrustumChange() })
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<RespawnEvent> { unloadWorld() })
|
||||
connection.registerEvent(CallbackEventInvoker.of<ChunkDataChangeEvent> { updateChunk(it.chunkPosition, it.chunk, true) })
|
||||
connection.registerEvent(CallbackEventInvoker.of<BlockSetEvent> { updateSection(it.blockPosition.chunkPosition, it.blockPosition.sectionHeight) })
|
||||
connection.registerEvent(CallbackEventInvoker.of<MassBlockSetEvent> {
|
||||
@ -136,6 +134,22 @@ class WorldRenderer(
|
||||
connection.registerEvent(CallbackEventInvoker.of<ChunkUnloadEvent> { unloadChunk(it.chunkPosition) })
|
||||
}
|
||||
|
||||
private fun unloadWorld() {
|
||||
renderWindow.queue += {
|
||||
for (sections in meshes.values) {
|
||||
for (mesh in sections.values) {
|
||||
mesh.unload()
|
||||
}
|
||||
}
|
||||
meshes.clear()
|
||||
incomplete.clear()
|
||||
queue.clear()
|
||||
visibleOpaque.clear()
|
||||
visibleTranslucent.clear()
|
||||
visibleTransparent.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private fun unloadChunk(chunkPosition: Vec2i) {
|
||||
incomplete -= chunkPosition
|
||||
renderWindow.queue += { queue.remove(chunkPosition) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user