From 0df6f16c64ac81beaa999b178141e663e6d9af2b Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sun, 28 Aug 2022 21:20:06 +0200 Subject: [PATCH] bump kutil to 1.15 * This finally fixes some interrupting issues and missing chunks --- pom.xml | 2 +- .../minosoft/gui/rendering/world/WorldRenderer.kt | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 483a36fae..a70f466d4 100644 --- a/pom.xml +++ b/pom.xml @@ -510,7 +510,7 @@ de.bixilon kutil - 1.14.1 + 1.15 io.netty diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt index bdee8f4fa..d8c2c8fc7 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt @@ -102,6 +102,7 @@ class WorldRenderer( private val preparingTasks: MutableSet = mutableSetOf() // current running section preparing tasks private val preparingTasksLock = SimpleLock() + @Volatile private var workingOnQueue = false private val queue: MutableList = mutableListOf() // queue, that is visible, and should be rendered private val queueSet: MutableSet = HashSet() // queue, that is visible, and should be rendered @@ -265,8 +266,8 @@ class WorldRenderer( renderWindow.inputHandler.registerKeyCallback( "minosoft:clear_chunk_cache".toResourceLocation(), KeyBinding( - KeyActions.MODIFIER to setOf(KeyCodes.KEY_F3), - KeyActions.PRESS to setOf(KeyCodes.KEY_A), + KeyActions.MODIFIER to setOf(KeyCodes.KEY_F3), + KeyActions.PRESS to setOf(KeyCodes.KEY_A), ) ) { clearChunkCache() } @@ -448,19 +449,20 @@ class WorldRenderer( } workingOnQueue = true + val items: MutableList = mutableListOf() queueLock.lock() for (i in 0 until maxPreparingTasks - size) { if (queue.isEmpty()) { break } - val item = queue.removeAt(0) + val item = queue.removeFirst() queueSet.remove(item) items += item } queueLock.unlock() for (item in items) { - val task = SectionPrepareTask(item.chunkPosition, item.sectionHeight, ThreadPoolRunnable(if (item.chunkPosition == cameraChunkPosition) HIGH else LOW, interuptable = true)) // Our own chunk is the most important one ToDo: Also make neighbour chunks important + val task = SectionPrepareTask(item.chunkPosition, item.sectionHeight, ThreadPoolRunnable(if (item.chunkPosition == cameraChunkPosition) HIGH else LOW, interruptable = true)) // Our own chunk is the most important one ToDo: Also make neighbour chunks important task.runnable.runnable = Runnable { prepareItem(item, task, task.runnable) } @@ -490,7 +492,7 @@ class WorldRenderer( return queueItemUnload(item) } item.mesh = mesh - runnable.interuptable = false + runnable.interruptable = false meshesToLoadLock.lock() if (meshesToLoadSet.remove(item)) { meshesToLoad.remove(item) // Remove duplicates @@ -509,6 +511,7 @@ class WorldRenderer( throw exception } } finally { + task.runnable.interruptable = false preparingTasksLock.lock() preparingTasks -= task preparingTasksLock.unlock()