From c1fa6d5829bf1de55e07c8cb69b5a024e3e9c317 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sat, 10 Apr 2021 18:03:07 +0200 Subject: [PATCH] rendering: fix rotations wrong way --- .../gui/rendering/TintColorCalculator.kt | 16 +++++++--------- .../chunk/models/renderable/ElementRenderer.kt | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/TintColorCalculator.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/TintColorCalculator.kt index bae8cfb3a..b4082da26 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/TintColorCalculator.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/TintColorCalculator.kt @@ -51,16 +51,14 @@ class TintColorCalculator(val world: World) { for (z in blendStart.z until blendEnd.z) { - for (y in blendStart.y until blendEnd.y) { - for (x in blendStart.x until blendEnd.x) { - val blendBlockPosition = Vec3i(x, y, z) - getTint(world.getBiome(blendBlockPosition), blockState, blendBlockPosition)?.let { - totalRed += it.red - totalGreen += it.green - totalBlue += it.blue + for (x in blendStart.x until blendEnd.x) { + val blendBlockPosition = Vec3i(x, blockPosition.y, z) + getTint(world.getBiome(blendBlockPosition), blockState, blendBlockPosition)?.let { + totalRed += it.red + totalGreen += it.green + totalBlue += it.blue - count++ - } + count++ } } } 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 a20e8ee34..149cb45bf 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 @@ -133,18 +133,18 @@ class ElementRenderer( if (rotation == VecUtil.EMPTY_VEC3) { return direction } - var rotatedDirectionVector = direction.floatDirectionVector.rotate(rotation.x, Axes.X) + var rotatedDirectionVector = direction.floatDirectionVector.rotate(-rotation.x, Axes.X) rotatedDirectionVector = rotatedDirectionVector.rotate(rotation.y, Axes.Y) - return Directions.byDirection(rotatedDirectionVector.rotate(rotation.z, Axes.Z)) + return Directions.byDirection(rotatedDirectionVector.rotate(-rotation.z, Axes.Z)) } fun rotatePositionsAxes(positions: Array, angles: Vec3, rescale: Boolean) { if (angles == VecUtil.EMPTY_VEC3) { return } - BlockModelElement.rotatePositions(positions, Axes.X, angles.x, VecUtil.EMPTY_VEC3, rescale) + BlockModelElement.rotatePositions(positions, Axes.X, -angles.x, VecUtil.EMPTY_VEC3, rescale) BlockModelElement.rotatePositions(positions, Axes.Y, angles.y, VecUtil.EMPTY_VEC3, rescale) - BlockModelElement.rotatePositions(positions, Axes.Z, angles.z, VecUtil.EMPTY_VEC3, rescale) + BlockModelElement.rotatePositions(positions, Axes.Z, -angles.z, VecUtil.EMPTY_VEC3, rescale) } val POSITION_1 = Vec3(-0.5f, -0.5f, -0.5f)