mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
fix eros account selection bug, fix world renderer crash, fixes #58
This commit is contained in:
parent
dbdd34ed34
commit
7e09ee1298
@ -146,11 +146,12 @@ class MainErosController : JavaFXWindowController() {
|
|||||||
DefaultThreadPool += {
|
DefaultThreadPool += {
|
||||||
try {
|
try {
|
||||||
account.verify(profile.clientToken)
|
account.verify(profile.clientToken)
|
||||||
|
onSuccess(account)
|
||||||
} catch (exception: Throwable) {
|
} catch (exception: Throwable) {
|
||||||
|
exception.printStackTrace()
|
||||||
Platform.runLater { activity = ErosMainActivities.ACCOUNT }
|
Platform.runLater { activity = ErosMainActivities.ACCOUNT }
|
||||||
// ToDo: Show account window and do account error handling
|
// ToDo: Show account window and do account error handling
|
||||||
}
|
}
|
||||||
onSuccess(account)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class ParticleRenderer(
|
|||||||
}
|
}
|
||||||
private var maxAmount = RenderConstants.MAXIMUM_PARTICLE_AMOUNT
|
private var maxAmount = RenderConstants.MAXIMUM_PARTICLE_AMOUNT
|
||||||
set(value) {
|
set(value) {
|
||||||
check(value > 1) { "Can not have negative particle mac amount" }
|
check(value > 1) { "Can not have negative particle max amount" }
|
||||||
particlesLock.lock()
|
particlesLock.lock()
|
||||||
while (particles.size > value) {
|
while (particles.size > value) {
|
||||||
particles.removeAt(0)
|
particles.removeAt(0)
|
||||||
|
@ -69,6 +69,7 @@ import de.bixilon.minosoft.util.KUtil.unsafeCast
|
|||||||
import de.bixilon.minosoft.util.ReadWriteLock
|
import de.bixilon.minosoft.util.ReadWriteLock
|
||||||
import de.bixilon.minosoft.util.chunk.ChunkUtil
|
import de.bixilon.minosoft.util.chunk.ChunkUtil
|
||||||
import de.bixilon.minosoft.util.chunk.ChunkUtil.isInViewDistance
|
import de.bixilon.minosoft.util.chunk.ChunkUtil.isInViewDistance
|
||||||
|
import de.bixilon.minosoft.util.chunk.ChunkUtil.loaded
|
||||||
import de.bixilon.minosoft.util.task.pool.DefaultThreadPool
|
import de.bixilon.minosoft.util.task.pool.DefaultThreadPool
|
||||||
import de.bixilon.minosoft.util.task.pool.ThreadPool.Priorities.HIGH
|
import de.bixilon.minosoft.util.task.pool.ThreadPool.Priorities.HIGH
|
||||||
import de.bixilon.minosoft.util.task.pool.ThreadPool.Priorities.LOW
|
import de.bixilon.minosoft.util.task.pool.ThreadPool.Priorities.LOW
|
||||||
@ -99,6 +100,7 @@ class WorldRenderer(
|
|||||||
|
|
||||||
val maxPreparingTasks = maxOf(DefaultThreadPool.threadCount - 1, 1)
|
val maxPreparingTasks = maxOf(DefaultThreadPool.threadCount - 1, 1)
|
||||||
private val preparingTasks: MutableSet<SectionPrepareTask> = synchronizedSetOf() // current running section preparing tasks
|
private val preparingTasks: MutableSet<SectionPrepareTask> = synchronizedSetOf() // current running section preparing tasks
|
||||||
|
private val preparingTasksLock = ReadWriteLock()
|
||||||
|
|
||||||
private val queue: MutableList<WorldQueueItem> = synchronizedListOf() // queue, that is visible, and should be rendered
|
private val queue: MutableList<WorldQueueItem> = synchronizedListOf() // queue, that is visible, and should be rendered
|
||||||
private val queueLock = ReadWriteLock()
|
private val queueLock = ReadWriteLock()
|
||||||
@ -296,11 +298,13 @@ class WorldRenderer(
|
|||||||
|
|
||||||
meshesToLoad.removeAll { !isChunkVisible(it.chunkPosition) }
|
meshesToLoad.removeAll { !isChunkVisible(it.chunkPosition) }
|
||||||
|
|
||||||
|
preparingTasksLock.acquire()
|
||||||
for (task in preparingTasks.toMutableSet()) {
|
for (task in preparingTasks.toMutableSet()) {
|
||||||
if (!isChunkVisible(task.chunkPosition)) {
|
if (!isChunkVisible(task.chunkPosition)) {
|
||||||
task.runnable.interrupt()
|
task.runnable.interrupt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
preparingTasksLock.release()
|
||||||
|
|
||||||
loadedMeshesLock.unlock()
|
loadedMeshesLock.unlock()
|
||||||
queueLock.unlock()
|
queueLock.unlock()
|
||||||
@ -349,9 +353,11 @@ class WorldRenderer(
|
|||||||
|
|
||||||
clearVisibleNextFrame = true
|
clearVisibleNextFrame = true
|
||||||
|
|
||||||
|
preparingTasksLock.acquire()
|
||||||
for (task in preparingTasks.toMutableSet()) {
|
for (task in preparingTasks.toMutableSet()) {
|
||||||
task.runnable.interrupt()
|
task.runnable.interrupt()
|
||||||
}
|
}
|
||||||
|
preparingTasksLock.release()
|
||||||
|
|
||||||
loadedMeshesLock.unlock()
|
loadedMeshesLock.unlock()
|
||||||
queueLock.unlock()
|
queueLock.unlock()
|
||||||
@ -373,11 +379,13 @@ class WorldRenderer(
|
|||||||
|
|
||||||
meshesToLoad.removeAll { it.chunkPosition == chunkPosition }
|
meshesToLoad.removeAll { it.chunkPosition == chunkPosition }
|
||||||
|
|
||||||
|
preparingTasksLock.acquire()
|
||||||
for (task in preparingTasks.toMutableSet()) {
|
for (task in preparingTasks.toMutableSet()) {
|
||||||
if (task.chunkPosition == chunkPosition) {
|
if (task.chunkPosition == chunkPosition) {
|
||||||
task.runnable.interrupt()
|
task.runnable.interrupt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
preparingTasksLock.release()
|
||||||
if (meshes != null) {
|
if (meshes != null) {
|
||||||
for (mesh in meshes.values) {
|
for (mesh in meshes.values) {
|
||||||
meshesToUnload += mesh
|
meshesToUnload += mesh
|
||||||
@ -416,20 +424,20 @@ class WorldRenderer(
|
|||||||
for (item in items) {
|
for (item in items) {
|
||||||
val task = SectionPrepareTask(item.chunkPosition, ThreadPoolRunnable(if (item.chunkPosition == cameraChunkPosition) HIGH else LOW)) // Our own chunk is the most important one ToDo: Also make neighbour chunks important
|
val task = SectionPrepareTask(item.chunkPosition, ThreadPoolRunnable(if (item.chunkPosition == cameraChunkPosition) HIGH else LOW)) // Our own chunk is the most important one ToDo: Also make neighbour chunks important
|
||||||
task.runnable.runnable = Runnable {
|
task.runnable.runnable = Runnable {
|
||||||
|
|
||||||
fun end() {
|
|
||||||
preparingTasks -= task
|
|
||||||
workQueue()
|
|
||||||
}
|
|
||||||
|
|
||||||
var locked = false
|
var locked = false
|
||||||
try {
|
try {
|
||||||
val chunk = item.chunk ?: world[item.chunkPosition] ?: return@Runnable end()
|
val chunk = item.chunk ?: world[item.chunkPosition] ?: return@Runnable
|
||||||
val section = chunk[item.sectionHeight] ?: return@Runnable end()
|
val section = chunk[item.sectionHeight] ?: return@Runnable
|
||||||
if (section.blocks.isEmpty) {
|
if (section.blocks.isEmpty) {
|
||||||
return@Runnable end()
|
return@Runnable
|
||||||
|
}
|
||||||
|
val neighbourChunks: Array<Chunk>
|
||||||
|
world.getChunkNeighbours(item.chunkPosition).let {
|
||||||
|
if (!it.loaded) {
|
||||||
|
return@Runnable queueSection(item.chunkPosition, item.sectionHeight, chunk, section)
|
||||||
|
}
|
||||||
|
neighbourChunks = it.unsafeCast()
|
||||||
}
|
}
|
||||||
val neighbourChunks: Array<Chunk> = world.getChunkNeighbours(item.chunkPosition).unsafeCast()
|
|
||||||
val neighbours = item.neighbours ?: ChunkUtil.getDirectNeighbours(neighbourChunks, chunk, item.sectionHeight)
|
val neighbours = item.neighbours ?: ChunkUtil.getDirectNeighbours(neighbourChunks, chunk, item.sectionHeight)
|
||||||
val mesh = WorldMesh(renderWindow, item.chunkPosition, item.sectionHeight)
|
val mesh = WorldMesh(renderWindow, item.chunkPosition, item.sectionHeight)
|
||||||
solidSectionPreparer.prepareSolid(item.chunkPosition, item.sectionHeight, chunk, section, neighbours, neighbourChunks, mesh)
|
solidSectionPreparer.prepareSolid(item.chunkPosition, item.sectionHeight, chunk, section, neighbours, neighbourChunks, mesh)
|
||||||
@ -437,7 +445,7 @@ class WorldRenderer(
|
|||||||
fluidSectionPreparer.prepareFluid(item.chunkPosition, item.sectionHeight, chunk, section, neighbours, neighbourChunks, mesh)
|
fluidSectionPreparer.prepareFluid(item.chunkPosition, item.sectionHeight, chunk, section, neighbours, neighbourChunks, mesh)
|
||||||
}
|
}
|
||||||
if (mesh.clearEmpty() == 0) {
|
if (mesh.clearEmpty() == 0) {
|
||||||
return@Runnable end()
|
return@Runnable
|
||||||
}
|
}
|
||||||
item.mesh = mesh
|
item.mesh = mesh
|
||||||
meshesToLoadLock.lock()
|
meshesToLoadLock.lock()
|
||||||
@ -454,16 +462,20 @@ class WorldRenderer(
|
|||||||
if (locked) {
|
if (locked) {
|
||||||
meshesToLoadLock.unlock()
|
meshesToLoadLock.unlock()
|
||||||
}
|
}
|
||||||
if (exception is InterruptedException) {
|
if (exception !is InterruptedException) {
|
||||||
// task got interrupted (probably because of chunk unload)
|
// otherwise task got interrupted (probably because of chunk unload)
|
||||||
preparingTasks -= task
|
|
||||||
return@Runnable
|
|
||||||
}
|
|
||||||
throw exception
|
throw exception
|
||||||
}
|
}
|
||||||
end()
|
} finally {
|
||||||
|
preparingTasksLock.lock()
|
||||||
|
preparingTasks -= task
|
||||||
|
preparingTasksLock.unlock()
|
||||||
|
workQueue()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
preparingTasksLock.lock()
|
||||||
preparingTasks += task
|
preparingTasks += task
|
||||||
|
preparingTasksLock.unlock()
|
||||||
DefaultThreadPool += task.runnable
|
DefaultThreadPool += task.runnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,6 +484,13 @@ class WorldRenderer(
|
|||||||
if (!chunk.isFullyLoaded || section.blocks.isEmpty) { // ToDo: Unload if empty
|
if (!chunk.isFullyLoaded || section.blocks.isEmpty) { // ToDo: Unload if empty
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// ToDo: The chunk needs to be fully loaded!
|
||||||
|
val neighbours = world.getChunkNeighbours(chunkPosition)
|
||||||
|
if(!neighbours.loaded){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
val visible = ignoreFrustum || isSectionVisible(chunkPosition, sectionHeight, section.blocks.minPosition, section.blocks.maxPosition, true)
|
val visible = ignoreFrustum || isSectionVisible(chunkPosition, sectionHeight, section.blocks.minPosition, section.blocks.maxPosition, true)
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user