mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
clarify the StackOverflow catch in SectionOcclusion::floodFill
This commit is contained in:
parent
97e6cd11cf
commit
8f1247d4b1
@ -14,9 +14,11 @@
|
||||
package de.bixilon.minosoft.data.direction
|
||||
|
||||
import de.bixilon.minosoft.data.Axes
|
||||
import de.bixilon.minosoft.data.text.formatting.TextFormattable
|
||||
import de.bixilon.minosoft.util.KUtil.format
|
||||
|
||||
@JvmInline
|
||||
value class DirectionVector private constructor(val value: Int) {
|
||||
value class DirectionVector private constructor(val value: Int) : TextFormattable {
|
||||
constructor() : this(0)
|
||||
|
||||
inline val x: Int get() = Integer.signum((value and (MASK shl SHIFT_X)) shl (Int.SIZE_BITS - SHIFT_X - BITS))
|
||||
@ -41,6 +43,12 @@ value class DirectionVector private constructor(val value: Int) {
|
||||
return DirectionVector(without or (value shl shift))
|
||||
}
|
||||
|
||||
inline operator fun component1() = x
|
||||
inline operator fun component2() = y
|
||||
inline operator fun component3() = z
|
||||
|
||||
override fun toText() = "(${this.x.format()} ${this.y.format()} ${this.z.format()})"
|
||||
override fun toString() = "v($x $y $z)"
|
||||
|
||||
companion object {
|
||||
const val BITS = 2
|
||||
|
@ -55,13 +55,10 @@ class SectionOcclusion(
|
||||
val regions = floodFill(array)
|
||||
update(calculateOcclusion(regions), notify)
|
||||
} catch (error: StackOverflowError) {
|
||||
try {
|
||||
val regions = floodFill(array)
|
||||
update(calculateOcclusion(regions), notify)
|
||||
} catch (error: StackOverflowError) {
|
||||
println("Error: ${provider.section.chunk.position}; h=${provider.section.height} (ss=${error.stackTrace.size})")
|
||||
error.printStackTrace()
|
||||
}
|
||||
// TODO: This is really stupid. The stack is large enough and still at some rare moments the method is crashing with an StackOverflow error.
|
||||
// BUT: When running the EXACT same code again, it magically works and does not crash with an error. Stupid JVM.
|
||||
val regions = floodFill(array)
|
||||
update(calculateOcclusion(regions), notify)
|
||||
} finally {
|
||||
ALLOCATOR.free(array)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user