mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -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) {
|
private fun WorldRenderer.awaitQueue(count: Int) {
|
||||||
for (i in 0 until 2000) {
|
for (i in 0 until 200) {
|
||||||
Thread.sleep(16)
|
Thread.sleep(16)
|
||||||
frame()
|
frame()
|
||||||
if (loaded.size == count) {
|
if (loaded.size == count) {
|
||||||
@ -73,6 +73,7 @@ class WorldRendererTest {
|
|||||||
Assert.assertEquals(renderer.loaded.size, 1)
|
Assert.assertEquals(renderer.loaded.size, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(invocationCount = 10)
|
||||||
fun queueMultipleChunks() {
|
fun queueMultipleChunks() {
|
||||||
val chunks = setOf(
|
val chunks = setOf(
|
||||||
RenderTestUtil.context.connection.world[Vec2i(0, 0)]!!,
|
RenderTestUtil.context.connection.world[Vec2i(0, 0)]!!,
|
||||||
@ -82,6 +83,7 @@ class WorldRendererTest {
|
|||||||
)
|
)
|
||||||
for (chunk in chunks) {
|
for (chunk in chunks) {
|
||||||
chunk[Vec3i(0, 0, 0)] = StoneTestO.state
|
chunk[Vec3i(0, 0, 0)] = StoneTestO.state
|
||||||
|
chunk[Vec3i(0, 16, 0)] = StoneTestO.state
|
||||||
}
|
}
|
||||||
val renderer = create()
|
val renderer = create()
|
||||||
for (chunk in chunks) {
|
for (chunk in chunks) {
|
||||||
|
@ -197,7 +197,7 @@ class WorldRenderer(
|
|||||||
loaded.unload(position.position, position.sectionHeight, false)
|
loaded.unload(position.position, position.sectionHeight, false)
|
||||||
culledQueue.remove(position.position, position.sectionHeight, false)
|
culledQueue.remove(position.position, position.sectionHeight, false)
|
||||||
meshingQueue.remove(position, false)
|
meshingQueue.remove(position, false)
|
||||||
loadingQueue.abort(position.position, false)
|
loadingQueue.abort(position, false)
|
||||||
meshingQueue.tasks.interrupt(position.position, position.sectionHeight)
|
meshingQueue.tasks.interrupt(position.position, position.sectionHeight)
|
||||||
|
|
||||||
lock.unlock()
|
lock.unlock()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* 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.
|
* 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()
|
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) {
|
fun cleanup(lock: Boolean) {
|
||||||
val remove: MutableSet<QueuePosition> = mutableSetOf()
|
val remove: MutableSet<QueuePosition> = mutableSetOf()
|
||||||
@ -123,7 +131,7 @@ class MeshLoadingQueue(
|
|||||||
return@removeAll true
|
return@removeAll true
|
||||||
}
|
}
|
||||||
|
|
||||||
this.meshes.removeAll { QueuePosition(it) in remove }
|
this.meshes.removeAll { QueuePosition(it) in remove; }
|
||||||
if (lock) unlock()
|
if (lock) unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* 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.
|
* 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 {
|
private fun canQueue(): Boolean {
|
||||||
val state = renderer.context.state
|
val state = renderer.context.state
|
||||||
if (state == RenderingStates.PAUSED || state == RenderingStates.STOPPED || state == RenderingStates.QUITTING) {
|
return !(state == RenderingStates.PAUSED || state == RenderingStates.STOPPED || state == RenderingStates.QUITTING)
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user