diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/Camera.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/Camera.kt index 24ba7eda3..689621056 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/Camera.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/Camera.kt @@ -256,19 +256,21 @@ class Camera( } private fun sendPositionToServer() { - if (System.currentTimeMillis() - lastMovementPacketSent > ProtocolDefinition.TICK_TIME) { - if (!currentPositionSent && !currentPositionSent) { - connection.sendPacket(PacketPlayerPositionAndRotationSending(cameraPosition - Vec3(0, PLAYER_HEIGHT, 0), EntityRotation(yaw, pitch), false)) - } else if (!currentPositionSent) { - connection.sendPacket(PacketPlayerPositionSending(cameraPosition - Vec3(0, PLAYER_HEIGHT, 0), false)) - } else { - connection.sendPacket(PacketPlayerRotationSending(EntityRotation(yaw, pitch), false)) - } - lastMovementPacketSent = System.currentTimeMillis() - currentPositionSent = true - currentRotationSent = true + if (System.currentTimeMillis() - lastMovementPacketSent < ProtocolDefinition.TICK_TIME) { return } + + if (!currentPositionSent && !currentPositionSent) { + connection.sendPacket(PacketPlayerPositionAndRotationSending(cameraPosition - Vec3(0, PLAYER_HEIGHT, 0), EntityRotation(yaw, pitch), false)) + } else if (!currentPositionSent) { + connection.sendPacket(PacketPlayerPositionSending(cameraPosition - Vec3(0, PLAYER_HEIGHT, 0), false)) + } else { + connection.sendPacket(PacketPlayerRotationSending(EntityRotation(yaw, pitch), false)) + } + lastMovementPacketSent = System.currentTimeMillis() + currentPositionSent = true + currentRotationSent = true + return } fun setPosition(position: Vec3) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt index a7fc9ec2d..fd985b88b 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt @@ -65,7 +65,7 @@ class BlockRenderer : BlockRenderInterface { for (direction in Directions.DIRECTIONS) { var directionIsCullFace: Boolean? = null var directionIsNotTransparent: Boolean? = null - var faceBorderSites: MutableList = mutableListOf() + val faceBorderSites: MutableList = mutableListOf() for (element in elements) { if (element.isCullFace(direction)) { directionIsCullFace = true @@ -102,7 +102,9 @@ class BlockRenderer : BlockRenderInterface { val invertedDirection = direction.inverse var isNeighbourTransparent = false var neighbourFaceSize: Array? = null - neighbourBlocks[direction.ordinal]?.getBlockRenderer(blockPosition + direction)?.let { + val neighbourBlock = neighbourBlocks[direction.ordinal] + // ToDo: We need to rotate the direction first and then rotate it + neighbourBlock?.getBlockRenderer(blockPosition + direction)?.let { if (it.transparentFaces[invertedDirection.ordinal]) { isNeighbourTransparent = true } @@ -114,7 +116,6 @@ class BlockRenderer : BlockRenderInterface { for (element in elements) { var drawElementFace = true - neighbourFaceSize?.let { // force draw transparent faces if (transparentFaces[direction.ordinal] || isNeighbourTransparent) { @@ -129,9 +130,8 @@ class BlockRenderer : BlockRenderInterface { if (elementFaceBorderSize.end.x > size.end.x || elementFaceBorderSize.end.y > size.end.y) { return@let } - drawElementFace = false - break } + drawElementFace = false } if (!drawElementFace) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt index 31cd5bb83..0f5cf91ad 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt @@ -74,7 +74,7 @@ class ElementRenderer(parent: BlockModelElement, val rotation: Vec3, uvLock: Boo val face = faces[realDirection] ?: return // Not our face val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[realDirection.ordinal] - val texture = textureMapping[face.textureName] ?: TODO() + val texture = textureMapping[face.textureName] ?: TODO("Unknown texture used ${face.textureName}") val lightLevel = lightAccessor.getLightLevel(blockPosition + directionMapping[face.cullFace]) // ToDo: rotate cullface diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt index 50639f892..89cc28da4 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt @@ -15,11 +15,9 @@ import de.bixilon.minosoft.gui.rendering.textures.Texture import de.bixilon.minosoft.gui.rendering.util.VecUtil import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus import glm_.glm -import glm_.mat4x4.Mat4 import glm_.vec2.Vec2 import glm_.vec3.Vec3 import glm_.vec3.Vec3i -import glm_.vec4.Vec4 class FluidRenderer( private val stillTextureName: String, @@ -35,8 +33,6 @@ class FluidRenderer( if (!RenderConstants.RENDER_FLUIDS) { return } - - val modelMatrix = Mat4().translate(Vec3(blockPosition)) val lightLevel = lightAccessor.getLightLevel(blockPosition) val heights = calculateHeights(neighbourBlocks, blockState, world, blockPosition) val isFlowing = isLiquidFlowing(heights) @@ -63,7 +59,7 @@ class FluidRenderer( face.rotate(angle) val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[direction.ordinal] val drawPositions = arrayOf(positions[positionTemplate[0]], positions[positionTemplate[1]], positions[positionTemplate[2]], positions[positionTemplate[3]]) - createQuad(drawPositions, face.getTexturePositionArray(direction), texture, modelMatrix, meshCollection, tintColor, lightLevel) + createQuad(drawPositions, face.getTexturePositionArray(direction), texture, blockPosition, meshCollection, tintColor, lightLevel) } } @@ -110,13 +106,11 @@ class FluidRenderer( return heights.toSet().size != 1 // liquid is flowing, if not all of the heights are the same } - private fun createQuad(drawPositions: Array, texturePositions: Array, texture: Texture, modelMatrix: Mat4, meshCollection: ChunkMeshCollection, tintColor: RGBColor?, lightLevel: Int) { + private fun createQuad(drawPositions: Array, texturePositions: Array, texture: Texture, blockPosition: Vec3i, meshCollection: ChunkMeshCollection, tintColor: RGBColor?, lightLevel: Int) { val mesh = ElementRenderer.getMesh(meshCollection, texture.transparency) for (vertex in ElementRenderer.DRAW_ODER) { - val input = Vec4(drawPositions[vertex.first], 1.0f) - val output = modelMatrix * input mesh.addVertex( - position = output.toVec3(), + position = blockPosition plus drawPositions[vertex.first], textureCoordinates = texturePositions[vertex.second]!!, texture = texture, tintColor = tintColor,