@@ -8,15 +8,15 @@ object VisibilityChecker {
88 operator fun DoubleArray.component6 () = this [5 ]
99
1010 inline fun SafeContext.scanVisibleSurfaces (box : Box , resolution : Int , check : (Vec3d ) -> Unit ) {
11+ val shrunk = box.expand(- 0.025 )
1112 getVisibleSides(box).forEach { side ->
12- val shrunk = box.expand(- 0.025 )
1313 val (minX, minY, minZ, maxX, maxY, maxZ) = shrunk.bounds(side)
1414 val stepX = (maxX - minX) / resolution
1515 val stepY = (maxY - minY) / resolution
1616 val stepZ = (maxZ - minZ) / resolution
1717 for (i in 0 .. resolution) {
18+ val x = if (stepX != 0.0 ) minX + stepX * i else minX
1819 for (j in 0 .. resolution) {
19- val x = if (stepX != 0.0 ) minX + stepX * i else minX
2020 val y = if (stepY != 0.0 ) minY + stepY * j else minY
2121 val z = if (stepZ != 0.0 ) minZ + stepZ * ((if (stepX != 0.0 ) j else i)) else minZ
2222 check(Vec3d (x, y, z))
@@ -35,21 +35,16 @@ object VisibilityChecker {
3535 Direction .EAST -> doubleArrayOf(maxX, minY, minZ, maxX, maxY, maxZ)
3636 }
3737
38- fun SafeContext.getVisibleSides (box : Box ): List <Direction > {
38+ fun SafeContext.getVisibleSides (box : Box ): Set <Direction > {
3939 val visibleSides = EnumSet .noneOf(Direction ::class .java)
4040
4141 val eyePos = player.eyePos
4242 val center = box.center
4343
44- val halfX = box.lengthX / 2
45- val halfY = box.lengthY / 2
46- val halfZ = box.lengthZ / 2
47-
4844 return visibleSides
49- .checkAxis(eyePos.x - center.x, halfX, Direction .WEST , Direction .EAST )
50- .checkAxis(eyePos.y - center.y, halfY, Direction .DOWN , Direction .UP )
51- .checkAxis(eyePos.z - center.z, halfZ, Direction .NORTH , Direction .SOUTH )
52- .map { it }
45+ .checkAxis(eyePos.x - center.x, box.lengthX / 2 , Direction .WEST , Direction .EAST )
46+ .checkAxis(eyePos.y - center.y, box.lengthY / 2 , Direction .DOWN , Direction .UP )
47+ .checkAxis(eyePos.z - center.z, box.lengthZ / 2 , Direction .NORTH , Direction .SOUTH )
5348 }
5449
5550 private fun EnumSet<Direction>.checkAxis (
0 commit comments