mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
fix crash/freeze in particle renderer
This commit is contained in:
parent
357d40af4c
commit
aa7f5ca36e
@ -84,8 +84,6 @@ class ParticleRenderer(
|
|||||||
override fun update() {
|
override fun update() {
|
||||||
particleMesh.unload()
|
particleMesh.unload()
|
||||||
transparentParticleMesh.unload()
|
transparentParticleMesh.unload()
|
||||||
particleMesh = ParticleMesh(renderWindow, particles.size)
|
|
||||||
transparentParticleMesh = ParticleMesh(renderWindow, 500)
|
|
||||||
|
|
||||||
val toRemove: MutableSet<Particle> = mutableSetOf()
|
val toRemove: MutableSet<Particle> = mutableSetOf()
|
||||||
|
|
||||||
@ -95,6 +93,9 @@ class ParticleRenderer(
|
|||||||
particleQueue.clear()
|
particleQueue.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
particleMesh = ParticleMesh(renderWindow, particles.size)
|
||||||
|
transparentParticleMesh = ParticleMesh(renderWindow, 500)
|
||||||
|
|
||||||
for (particle in particles) {
|
for (particle in particles) {
|
||||||
particle.tryTick()
|
particle.tryTick()
|
||||||
if (particle.dead) {
|
if (particle.dead) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
package de.bixilon.minosoft.util.collections
|
package de.bixilon.minosoft.util.collections
|
||||||
|
|
||||||
class ArrayFloatList(
|
class ArrayFloatList(
|
||||||
private val initialSize: Int = 1000,
|
private val initialSize: Int = DEFAULT_INITIAL_SIZE,
|
||||||
) {
|
) {
|
||||||
private var data: FloatArray = FloatArray(initialSize)
|
private var data: FloatArray = FloatArray(initialSize)
|
||||||
val limit: Int
|
val limit: Int
|
||||||
@ -24,6 +24,12 @@ class ArrayFloatList(
|
|||||||
val isEmpty: Boolean
|
val isEmpty: Boolean
|
||||||
get() = size == 0
|
get() = size == 0
|
||||||
|
|
||||||
|
private val nextGrowStep = when {
|
||||||
|
initialSize <= 0 -> DEFAULT_INITIAL_SIZE
|
||||||
|
initialSize <= 50 -> 50
|
||||||
|
else -> initialSize
|
||||||
|
}
|
||||||
|
|
||||||
private var output: FloatArray = FloatArray(0)
|
private var output: FloatArray = FloatArray(0)
|
||||||
private var outputUpToDate = false
|
private var outputUpToDate = false
|
||||||
|
|
||||||
@ -39,7 +45,7 @@ class ArrayFloatList(
|
|||||||
}
|
}
|
||||||
var newSize = data.size
|
var newSize = data.size
|
||||||
while (newSize - size < needed) {
|
while (newSize - size < needed) {
|
||||||
newSize += initialSize
|
newSize += nextGrowStep
|
||||||
}
|
}
|
||||||
val oldData = data
|
val oldData = data
|
||||||
data = FloatArray(newSize)
|
data = FloatArray(newSize)
|
||||||
@ -78,4 +84,9 @@ class ArrayFloatList(
|
|||||||
checkOutputArray()
|
checkOutputArray()
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private const val DEFAULT_INITIAL_SIZE = 1000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user