mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 14:59:16 -04:00
section occlusion: don't trace inner regions
They are not needed and thrown away anyways. This makes performance better, because when the section is full, we only need to start 1536 blocks tracing and not all 4096
This commit is contained in:
parent
8b5e27a47f
commit
58a36aa454
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user