mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -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() {
|
||||
particleMesh.unload()
|
||||
transparentParticleMesh.unload()
|
||||
particleMesh = ParticleMesh(renderWindow, particles.size)
|
||||
transparentParticleMesh = ParticleMesh(renderWindow, 500)
|
||||
|
||||
val toRemove: MutableSet<Particle> = mutableSetOf()
|
||||
|
||||
@ -95,6 +93,9 @@ class ParticleRenderer(
|
||||
particleQueue.clear()
|
||||
}
|
||||
|
||||
particleMesh = ParticleMesh(renderWindow, particles.size)
|
||||
transparentParticleMesh = ParticleMesh(renderWindow, 500)
|
||||
|
||||
for (particle in particles) {
|
||||
particle.tryTick()
|
||||
if (particle.dead) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.util.collections
|
||||
|
||||
class ArrayFloatList(
|
||||
private val initialSize: Int = 1000,
|
||||
private val initialSize: Int = DEFAULT_INITIAL_SIZE,
|
||||
) {
|
||||
private var data: FloatArray = FloatArray(initialSize)
|
||||
val limit: Int
|
||||
@ -24,6 +24,12 @@ class ArrayFloatList(
|
||||
val isEmpty: Boolean
|
||||
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 outputUpToDate = false
|
||||
|
||||
@ -39,7 +45,7 @@ class ArrayFloatList(
|
||||
}
|
||||
var newSize = data.size
|
||||
while (newSize - size < needed) {
|
||||
newSize += initialSize
|
||||
newSize += nextGrowStep
|
||||
}
|
||||
val oldData = data
|
||||
data = FloatArray(newSize)
|
||||
@ -78,4 +84,9 @@ class ArrayFloatList(
|
||||
checkOutputArray()
|
||||
return output
|
||||
}
|
||||
|
||||
|
||||
private companion object {
|
||||
private const val DEFAULT_INITIAL_SIZE = 1000
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user