diff --git a/src/main/java/de/bixilon/minosoft/data/world/container/block/SectionOcclusion.kt b/src/main/java/de/bixilon/minosoft/data/world/container/block/SectionOcclusion.kt index 7d096dfeb..828dc4ba3 100644 --- a/src/main/java/de/bixilon/minosoft/data/world/container/block/SectionOcclusion.kt +++ b/src/main/java/de/bixilon/minosoft/data/world/container/block/SectionOcclusion.kt @@ -77,6 +77,7 @@ class SectionOcclusion( return false } + private fun trace(regions: ShortArray, position: InSectionPosition) = trace(regions, position, position.index.toShort()) private fun trace(regions: ShortArray, position: InSectionPosition, region: Short) { if (regions.setIfUnset(position, region)) return @@ -92,11 +93,18 @@ class SectionOcclusion( // mark regions and check direct neighbours Arrays.fill(array, EMPTY_REGION) - // TODO: Only start flood filling from sides (don't trace potential irrelevant regions in the middle) - // TODO: Keep track of direction and never go into negative again (we can't change the direction of the look; it can not refelct here) + // TODO: Keep track of direction and never go into negative again (we can't change the direction of the look; it can not reflect here) - for (index in 0 until ProtocolDefinition.BLOCKS_PER_SECTION) { - trace(array, InSectionPosition(index), index.toShort()) + + for (index in 0 until 256) { + trace(array, InSectionPosition((index shr 0) and 0x0F, 0x00, (index shr 4) and 0x0F)) + trace(array, InSectionPosition((index shr 0) and 0x0F, 0x0F, (index shr 4) and 0x0F)) + + trace(array, InSectionPosition((index shr 0) and 0x0F, (index shr 4) and 0x0F, 0x00)) + trace(array, InSectionPosition((index shr 0) and 0x0F, (index shr 4) and 0x0F, 0x0F)) + + trace(array, InSectionPosition(0x00, (index shr 4) and 0x0F, (index shr 0) and 0x0F)) + trace(array, InSectionPosition(0x0F, (index shr 4) and 0x0F, (index shr 0) and 0x0F)) } return array diff --git a/src/main/java/de/bixilon/minosoft/data/world/vec/SVec3.kt b/src/main/java/de/bixilon/minosoft/data/world/vec/SVec3.kt index 6646687ff..589bfcb79 100644 --- a/src/main/java/de/bixilon/minosoft/data/world/vec/SVec3.kt +++ b/src/main/java/de/bixilon/minosoft/data/world/vec/SVec3.kt @@ -30,8 +30,6 @@ value class SVec3(val raw: Int) { assertVec(z, -MAX_Z, MAX_Z) } - constructor(vector: DirectionVector) : this(vector.x, vector.y, vector.z) - inline val x: Int get() = (((raw ushr SHIFT_X) and MASK_X) shl (Int.SIZE_BITS - BITS_X)) shr (Int.SIZE_BITS - BITS_X) inline val y: Int get() = (((raw ushr SHIFT_Y) and MASK_Y) shl (Int.SIZE_BITS - BITS_Y)) shr (Int.SIZE_BITS - BITS_Y) @@ -131,5 +129,8 @@ value class SVec3(val raw: Int) { val EMPTY = SVec3(0, 0, 0) + + + operator fun invoke(vector: DirectionVector) = SVec3(vector.x, vector.y, vector.z) } }