mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 02:45:13 -04:00
properly remove chunk from loading queue
This should fix another missing chunk bug
This commit is contained in:
parent
a2624c4c43
commit
0f1b7f7e89
@ -32,7 +32,7 @@ class WorldRendererTest {
|
||||
}
|
||||
|
||||
private fun WorldRenderer.awaitQueue(count: Int) {
|
||||
for (i in 0 until 2000) {
|
||||
for (i in 0 until 200) {
|
||||
Thread.sleep(16)
|
||||
frame()
|
||||
if (loaded.size == count) {
|
||||
@ -73,6 +73,7 @@ class WorldRendererTest {
|
||||
Assert.assertEquals(renderer.loaded.size, 1)
|
||||
}
|
||||
|
||||
@Test(invocationCount = 10)
|
||||
fun queueMultipleChunks() {
|
||||
val chunks = setOf(
|
||||
RenderTestUtil.context.connection.world[Vec2i(0, 0)]!!,
|
||||
@ -82,6 +83,7 @@ class WorldRendererTest {
|
||||
)
|
||||
for (chunk in chunks) {
|
||||
chunk[Vec3i(0, 0, 0)] = StoneTestO.state
|
||||
chunk[Vec3i(0, 16, 0)] = StoneTestO.state
|
||||
}
|
||||
val renderer = create()
|
||||
for (chunk in chunks) {
|
||||
|
@ -197,7 +197,7 @@ class WorldRenderer(
|
||||
loaded.unload(position.position, position.sectionHeight, false)
|
||||
culledQueue.remove(position.position, position.sectionHeight, false)
|
||||
meshingQueue.remove(position, false)
|
||||
loadingQueue.abort(position.position, false)
|
||||
loadingQueue.abort(position, false)
|
||||
meshingQueue.tasks.interrupt(position.position, position.sectionHeight)
|
||||
|
||||
lock.unlock()
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -110,6 +110,14 @@ class MeshLoadingQueue(
|
||||
if (lock) unlock()
|
||||
}
|
||||
|
||||
fun abort(position: QueuePosition, lock: Boolean = true) {
|
||||
if (lock) lock()
|
||||
if (this.positions.remove(position)) {
|
||||
this.meshes.removeAll { it.chunkPosition == position.position && it.sectionHeight == position.sectionHeight }
|
||||
}
|
||||
if (lock) unlock()
|
||||
}
|
||||
|
||||
|
||||
fun cleanup(lock: Boolean) {
|
||||
val remove: MutableSet<QueuePosition> = mutableSetOf()
|
||||
@ -123,7 +131,7 @@ class MeshLoadingQueue(
|
||||
return@removeAll true
|
||||
}
|
||||
|
||||
this.meshes.removeAll { QueuePosition(it) in remove }
|
||||
this.meshes.removeAll { QueuePosition(it) in remove; }
|
||||
if (lock) unlock()
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -101,10 +101,7 @@ class ChunkQueueMaster(
|
||||
|
||||
private fun canQueue(): Boolean {
|
||||
val state = renderer.context.state
|
||||
if (state == RenderingStates.PAUSED || state == RenderingStates.STOPPED || state == RenderingStates.QUITTING) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return !(state == RenderingStates.PAUSED || state == RenderingStates.STOPPED || state == RenderingStates.QUITTING)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
Loading…
x
Reference in New Issue
Block a user