improve VoxelSide performance

This commit is contained in:
Bixilon 2022-11-10 16:44:39 +01:00
parent 07b4dda428
commit 775c6b3cfa
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 5 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.registries.shapes.VoxelShape
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSide
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSideSet
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
class DirectedProperty(
private val directions: BooleanArray,
@ -72,7 +73,7 @@ class DirectedProperty(
// ToDo: This whole calculation is technically wrong, it could be that 2 different sides of 2 blocks are "free". That means that light can still not pass the blocks, but
// this algorithm does not cover it. Let's see it as performance hack
val sides: MutableSet<VoxelSide> = mutableSetOf()
val sides: MutableSet<VoxelSide> = ObjectOpenHashSet()
for (aabb in this) {
when (side.axis) {

View File

@ -13,6 +13,8 @@
package de.bixilon.minosoft.data.registries.shapes.side
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
class VoxelSideSet(
val sides: Set<VoxelSide>,
) : Iterable<VoxelSide> {
@ -28,7 +30,7 @@ class VoxelSideSet(
return this
}
val next: MutableSet<VoxelSide> = mutableSetOf()
val next: MutableSet<VoxelSide> = ObjectOpenHashSet()
val array = this.sides.toTypedArray()
for (i in 1 until sides.size) {