From c2b5a58dd2e2f96245d3cd3613af4ec3e085d6b0 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sun, 30 Oct 2016 13:15:42 +0100 Subject: [PATCH] Fixes #2532: Work around bug in Forge lighting pipeline and UnpackedBakedQuad. --- .../render/model/AutoRotatingModel.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/appeng/client/render/model/AutoRotatingModel.java b/src/main/java/appeng/client/render/model/AutoRotatingModel.java index 6e601c99..ef4afc0d 100644 --- a/src/main/java/appeng/client/render/model/AutoRotatingModel.java +++ b/src/main/java/appeng/client/render/model/AutoRotatingModel.java @@ -88,8 +88,23 @@ public class AutoRotatingModel implements IBakedModel builder.setQuadOrientation( null ); } - BakedQuad q = builder.build(); - rotated.add( q ); + BakedQuad unpackedQuad = builder.build(); + + // Make a copy of it to resolve the vertex data and throw away the unpacked stuff + // This also fixes a bug in Forge's UnpackedBakedQuad, which unpacks a byte-based normal like 0,0,-1 + // to 0,0,-0.99607843. We replace these normals with the proper 0,0,-1 when rotation, which + // causes a bug in the AO lighter, if an unpacked quad pipes this value back to it. + // Packing it back to the vanilla vertex format will fix this inconsistency because it converts + // the normal back to a byte-based format, which then re-applies Forge's own bug when piping it + // to the AO lighter, thus fixing our problem. + BakedQuad packedQuad = new BakedQuad( unpackedQuad.getVertexData(), + quad.getTintIndex(), + unpackedQuad.getFace(), + quad.getSprite(), + quad.shouldApplyDiffuseLighting(), + quad.getFormat() + ); + rotated.add( packedQuad ); } return rotated; }