fix flood filling, use correct occlusion camera position

This commit is contained in:
Bixilon 2022-05-07 21:20:59 +02:00
parent 87da02943d
commit d6cd333ed4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 12 additions and 12 deletions

View File

@ -146,24 +146,23 @@ class BlockSectionDataProvider(
continue
}
val regionInt = region.toInt()
val override = regionOverride[regionInt]
if (y < ProtocolDefinition.SECTION_MAX_Y) {
val neighbourRegion = regions[(y + 1) shl 8 or (z shl 4) or x]
if (neighbourRegion > 0) {
regionOverride[regionInt] = neighbourRegion
if (neighbourRegion > 0 && region != neighbourRegion) {
regionOverride[regionInt] = maxOf(neighbourRegion, region)
}
}
if (z < ProtocolDefinition.SECTION_MAX_Z) {
val neighbourRegion = regions[y shl 8 or ((z + 1) shl 4) or x]
if (neighbourRegion > 0) {
regionOverride[regionInt] = neighbourRegion
if (neighbourRegion > 0 && region != neighbourRegion) {
regionOverride[regionInt] = maxOf(neighbourRegion, region)
}
}
if (x < ProtocolDefinition.SECTION_MAX_X) {
val neighbourRegion = regions[y shl 8 or (z shl 4) or (x + 1)]
if (neighbourRegion > 0) {
regionOverride[regionInt] = neighbourRegion
if (neighbourRegion > 0 && region != neighbourRegion) {
regionOverride[regionInt] = maxOf(neighbourRegion, region)
}
}
}

View File

@ -26,6 +26,9 @@ import de.bixilon.minosoft.gui.rendering.modding.events.CameraMatrixChangeEvent
import de.bixilon.minosoft.gui.rendering.modding.events.CameraPositionChangeEvent
import de.bixilon.minosoft.gui.rendering.modding.events.FrustumChangeEvent
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
import de.bixilon.minosoft.gui.rendering.util.VecUtil.blockPosition
import de.bixilon.minosoft.gui.rendering.util.VecUtil.chunkPosition
import de.bixilon.minosoft.gui.rendering.util.VecUtil.sectionHeight
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
@ -112,7 +115,8 @@ class MatrixHandler(
}
this.eyePosition = eyePosition
this.rotation = rotation
camera.visibilityGraph.updateCamera(entity.positionInfo.chunkPosition, entity.positionInfo.sectionHeight)
val cameraBlockPosition = eyePosition.blockPosition
camera.visibilityGraph.updateCamera(cameraBlockPosition.chunkPosition, cameraBlockPosition.sectionHeight)
if (fov != previousFOV || fogEnd != this.fogEnd) {
this.fogEnd = fogEnd
calculateProjectionMatrix()

View File

@ -196,7 +196,7 @@ class WorldVisibilityGraph(
}
}
val southIndex = BlockSectionDataProvider.getIndex(inverted, Directions.SOUTH)
if (directionVector.z >= 0 && (ignoreVisibility || chunk.sections?.get(sectionIndex)?.blocks?.isOccluded(sectionIndex) != true)) {
if (directionVector.z >= 0 && (ignoreVisibility || chunk.sections?.get(sectionIndex)?.blocks?.isOccluded(southIndex) != true)) {
val nextPosition = chunkPosition + Directions.SOUTH
val nextChunk = chunks[nextPosition]
if (nextChunk != null) {
@ -267,9 +267,6 @@ class WorldVisibilityGraph(
val graph: MutableMap<Vec2i, Array<BooleanArray>> = HashMap()
for (direction in Directions.VALUES) {
if (direction != Directions.DOWN) {
continue
}
val nextPosition = chunkPosition + direction
val nextChunk = chunks[nextPosition] ?: continue
val nextVisibility = graph.getOrPut(nextPosition) { createVisibilityArray() }