mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
world renderer: don't work on queue twice
This fixes major lags in the nether
This commit is contained in:
parent
6ba46c00c7
commit
8a00410527
@ -101,6 +101,7 @@ class WorldRenderer(
|
|||||||
private val preparingTasks: MutableSet<SectionPrepareTask> = mutableSetOf() // current running section preparing tasks
|
private val preparingTasks: MutableSet<SectionPrepareTask> = mutableSetOf() // current running section preparing tasks
|
||||||
private val preparingTasksLock = SimpleLock()
|
private val preparingTasksLock = SimpleLock()
|
||||||
|
|
||||||
|
private var workingOnQueue = false
|
||||||
private val queue: MutableList<WorldQueueItem> = mutableListOf() // queue, that is visible, and should be rendered
|
private val queue: MutableList<WorldQueueItem> = mutableListOf() // queue, that is visible, and should be rendered
|
||||||
private val queueSet: MutableSet<WorldQueueItem> = HashSet() // queue, that is visible, and should be rendered
|
private val queueSet: MutableSet<WorldQueueItem> = HashSet() // queue, that is visible, and should be rendered
|
||||||
private val queueLock = SimpleLock()
|
private val queueLock = SimpleLock()
|
||||||
@ -424,6 +425,12 @@ class WorldRenderer(
|
|||||||
if (size >= maxPreparingTasks && queue.isNotEmpty() || meshesToLoad.size >= maxMeshesToLoad) {
|
if (size >= maxPreparingTasks && queue.isNotEmpty() || meshesToLoad.size >= maxMeshesToLoad) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (workingOnQueue) {
|
||||||
|
// already working on the queue
|
||||||
|
return
|
||||||
|
}
|
||||||
|
workingOnQueue = true
|
||||||
|
|
||||||
val items: MutableList<WorldQueueItem> = mutableListOf()
|
val items: MutableList<WorldQueueItem> = mutableListOf()
|
||||||
queueLock.lock()
|
queueLock.lock()
|
||||||
for (i in 0 until maxPreparingTasks - size) {
|
for (i in 0 until maxPreparingTasks - size) {
|
||||||
@ -495,6 +502,7 @@ class WorldRenderer(
|
|||||||
preparingTasksLock.unlock()
|
preparingTasksLock.unlock()
|
||||||
DefaultThreadPool += task.runnable
|
DefaultThreadPool += task.runnable
|
||||||
}
|
}
|
||||||
|
workingOnQueue = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun queueItemUnload(item: WorldQueueItem) {
|
private fun queueItemUnload(item: WorldQueueItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user