From 7e667d483a99dc0830683521251cab5231dac5c3 Mon Sep 17 00:00:00 2001 From: octarine-noise Date: Tue, 29 Mar 2016 22:14:59 +0200 Subject: [PATCH] fixed Log block endcap UV rotations --- .../client/render/AbstractRenderColumn.kt | 19 +++++++++++-------- .../client/render/RenderAlgae.kt | 1 - .../client/render/RenderCactus.kt | 3 --- .../client/render/RenderCoral.kt | 1 - .../client/render/RenderGrass.kt | 3 +-- .../client/render/RenderLeaves.kt | 7 ++++--- .../client/render/RenderLilypad.kt | 2 -- .../client/render/RenderMycelium.kt | 1 - .../client/render/RenderNetherrack.kt | 1 - .../client/render/RenderReeds.kt | 1 - .../client/render/ModelRenderer.kt | 10 ++++++---- 11 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt b/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt index e524411..2f31534 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt @@ -100,9 +100,9 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl else -> null } - val bottomSquare = model { columnLidSquare() { it.rotate(rot(EAST) * 2 + rot(UP)) } } - val bottomRoundSmall = model { columnLid(radiusSmall) { it.rotate(rot(EAST) * 2 + rot(UP)) } } - val bottomRoundLarge = model { columnLid(radiusLarge) { it.rotate(rot(EAST) * 2 + rot(UP)) } } + val bottomSquare = model { columnLidSquare() { it.rotate(rot(EAST) * 2 + rot(UP)).mirrorUV(true, true) } } + val bottomRoundSmall = model { columnLid(radiusSmall) { it.rotate(rot(EAST) * 2 + rot(UP)).mirrorUV(true, true) } } + val bottomRoundLarge = model { columnLid(radiusLarge) { it.rotate(rot(EAST) * 2 + rot(UP)).mirrorUV(true, true) } } inline fun flatBottom(type: QuadrantType) = when(type) { SMALL_RADIUS -> bottomRoundSmall.model LARGE_RADIUS -> bottomRoundLarge.model @@ -171,7 +171,6 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl rotation, blockContext.blockCenter, icon = sideTexture, - rotateUV = { 0 }, postProcess = noPost ) @@ -227,8 +226,10 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl rotation, blockContext.blockCenter, icon = upIcon, - rotateUV = { if (shouldRotateUp) idx else 0 }, - postProcess = noPost + postProcess = { ctx, qi, q, vi, v -> + rotateUV((if (shouldRotateUp) idx else 0) + (if (logAxis == Axis.X) 1 else 0)) + if (logAxis == Axis.X) mirrorUV(true, true) + } ) if (downModel != null) modelRenderer.render( renderer, @@ -236,8 +237,10 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl rotation, blockContext.blockCenter, icon = downIcon, - rotateUV = { if (shouldRotateDown) 3 - idx else 0 }, - postProcess = noPost + postProcess = { ctx, qi, q, vi, v -> + rotateUV((if (shouldRotateDown) 3 - idx else 0) + (if (logAxis == Axis.X) 1 else 0)) + if (logAxis != Axis.Y) mirrorUV(true, true) + } ) } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderAlgae.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderAlgae.kt index 13f58d5..22a10e9 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderAlgae.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderAlgae.kt @@ -45,7 +45,6 @@ class RenderAlgae : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { algaeModels[rand[2]], Rotation.identity, icon = { ctx, qi, q -> algaeIcons[rand[qi and 1]]!! }, - rotateUV = { 0 }, postProcess = noPost ) } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderCactus.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderCactus.kt index 75970aa..c1d2fda 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderCactus.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderCactus.kt @@ -74,7 +74,6 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { icon = { ctx, qi, q -> when(qi) { 0 -> icons.bottomTexture; 1 -> icons.topTexture; else -> icons.sideTexture } }, - rotateUV = { 0 }, postProcess = noPost ) modelRenderer.render( @@ -82,7 +81,6 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { modelCross[ctx.random(0)], Rotation.identity, icon = { ctx, qi, q -> iconCross.icon!!}, - rotateUV = { 0 }, postProcess = noPost ) modelRenderer.render( @@ -90,7 +88,6 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { modelArm[ctx.random(1)], cactusArmRotation[ctx.random(2) % 4], icon = { ctx2, qi, q -> iconArm[ctx.random(3)]!!}, - rotateUV = { 0 }, postProcess = noPost ) return true diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderCoral.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderCoral.kt index d9f45c1..122868f 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderCoral.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderCoral.kt @@ -63,7 +63,6 @@ class RenderCoral : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { coralModels[variation++], rotationFromUp[idx], icon = { ctx, qi, q -> if (qi == 4) crustIcons[variation]!! else coralIcons[variation + (qi and 1)]!!}, - rotateUV = { 0 }, postProcess = noPost ) } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderGrass.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderGrass.kt index f899a28..1ff078b 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderGrass.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderGrass.kt @@ -70,8 +70,8 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { Rotation.identity, ctx.blockCenter, icon = { ctx, qi, q -> grassTopTexture }, - rotateUV = { 2 }, postProcess = { ctx, qi, q, vi, v -> + rotateUV(2) if (isSnowed) { if(!ctx.aoEnabled) setGrey(1.4f) } else if (ctx.aoEnabled) multiplyColor(blockColor) } @@ -101,7 +101,6 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { icon = { ctx: ShadingContext, qi: Int, q: Quad -> if (Config.shortGrass.useGenerated) iconGen.icon!! else iconset[rand[qi and 1]]!! }, - rotateUV = { 0 }, postProcess = { ctx, qi, q, vi, v -> if (isSnowed) setGrey(1.0f) else multiplyColor(grassInfo.overrideColor ?: blockColor) } ) } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt index f808aae..728c152 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt @@ -61,8 +61,10 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { rotation, ctx.blockCenter + perturbs[rand[0]], icon = { ctx, qi, q -> leafInfo.roundLeafTexture }, - rotateUV = { q -> rand[1] }, - postProcess = { ctx, qi, q, vi, v -> multiplyColor(blockColor) } + postProcess = { ctx, qi, q, vi, v -> + rotateUV(rand[1]) + multiplyColor(blockColor) + } ) } if (isSnowed) modelRenderer.render( @@ -71,7 +73,6 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { Rotation.identity, ctx.blockCenter + perturbs[rand[0]], icon = { ctx, qi, q -> snowedIcon[rand[1]]!! }, - rotateUV = { 0 }, postProcess = whitewash ) } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderLilypad.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderLilypad.kt index 76c29ca..eed4f08 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderLilypad.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderLilypad.kt @@ -55,7 +55,6 @@ class RenderLilypad : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { ctx.blockCenter.add(perturbs[rand[2]]), forceFlat = true, icon = { ctx, qi, q -> rootIcon[rand[qi and 1]]!! }, - rotateUV = { 0 }, postProcess = noPost ) } @@ -67,7 +66,6 @@ class RenderLilypad : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { ctx.blockCenter.add(perturbs[rand[4]]), forceFlat = true, icon = { ctx, qi, q -> flowerIcon[rand[0]]!! }, - rotateUV = { 0 }, postProcess = noPost ) diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderMycelium.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderMycelium.kt index 3520c9d..ac458cf 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderMycelium.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderMycelium.kt @@ -45,7 +45,6 @@ class RenderMycelium : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { Rotation.identity, ctx.blockCenter + (if (isSnowed) snowOffset else Double3.zero), icon = { ctx, qi, q -> myceliumIcon[rand[qi and 1]]!! }, - rotateUV = { 0 }, postProcess = if (isSnowed) whitewash else noPost ) diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderNetherrack.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderNetherrack.kt index db58a73..11d8ca6 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderNetherrack.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderNetherrack.kt @@ -47,7 +47,6 @@ class RenderNetherrack : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) netherrackModel[rand[0]], Rotation.identity, icon = { ctx, qi, q -> netherrackIcon[rand[qi and 1]]!! }, - rotateUV = { 0 }, postProcess = noPost ) diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderReeds.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderReeds.kt index a2e4be8..9bcbce1 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderReeds.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderReeds.kt @@ -62,7 +62,6 @@ class RenderReeds : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { Rotation.identity, forceFlat = true, icon = { ctx, qi, q -> reedIcons[iconVar]!! }, - rotateUV = { 0 }, postProcess = noPost ) } diff --git a/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt b/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt index d99f463..71d7283 100644 --- a/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt +++ b/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt @@ -32,7 +32,6 @@ class ModelRenderer() : ShadingContext() { trans: Double3 = blockContext.blockCenter, forceFlat: Boolean = false, icon: (ShadingContext, Int, Quad) -> TextureAtlasSprite?, - rotateUV: (Quad) -> Int, postProcess: RenderVertex.(ShadingContext, Int, Quad, Int, Vertex) -> Unit ) { rotation = rot @@ -44,13 +43,12 @@ class ModelRenderer() : ShadingContext() { model.quads.forEachIndexed { quadIdx, quad -> val drawIcon = icon(this, quadIdx, quad) if (drawIcon != null) { - val uvRot = rotateUV(quad) quad.verts.forEachIndexed { vertIdx, vert -> - temp.init(vert) - temp.rotate(rotation).translate(trans).rotateUV(uvRot).setIcon(drawIcon) + temp.init(vert).rotate(rotation).translate(trans) val shader = if (aoEnabled && !forceFlat) vert.aoShader else vert.flatShader shader.shade(this, temp) temp.postProcess(this, quadIdx, quad, vertIdx, vert) + temp.setIcon(drawIcon) worldRenderer .pos(temp.x, temp.y, temp.z) @@ -133,6 +131,10 @@ class RenderVertex() { else -> { return this } } } + inline fun mirrorUV(mirrorU: Boolean, mirrorV: Boolean) { + if (mirrorU) u = -u + if (mirrorV) v = -v + } inline fun setIcon(icon: TextureAtlasSprite): RenderVertex { u = (icon.maxU - icon.minU) * (u + 0.5) + icon.minU v = (icon.maxV - icon.minV) * (v + 0.5) + icon.minV