Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MutableQuadViewImpl#fromVanilla methods not setting correct normal flags #4350

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -300,6 +300,8 @@ default MutableQuadView normal(int vertexIndex, Vector3fc normal) {
* <p>The {@linkplain BakedQuad#getLightEmission() baked quad's light emission} will be applied to the lightmap
* values from the vertex data after copying.
*
* <p>Calling this method resets the {@link #tag()}.
*
* <p>Calling this method does not emit the quad.
*/
MutableQuadView fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace);
Original file line number Diff line number Diff line change
@@ -213,20 +213,30 @@ public final MutableQuadViewImpl fromVanilla(int[] quadData, int startIndex) {
System.arraycopy(quadData, startIndex, data, baseIndex + HEADER_STRIDE, VANILLA_QUAD_STRIDE);
isGeometryInvalid = true;

int normalFlags = 0;
int colorIndex = baseIndex + VERTEX_COLOR;
int normalIndex = baseIndex + VERTEX_NORMAL;

for (int i = 0; i < 4; i++) {
data[colorIndex] = ColorHelper.fromVanillaColor(data[colorIndex]);

// Set normal flag if normal is not zero, ignoring W component
if ((data[normalIndex] & 0xFFFFFF) != 0) {
normalFlags |= 1 << i;
}

colorIndex += VERTEX_STRIDE;
normalIndex += VERTEX_STRIDE;
}

normalFlags(normalFlags);
return this;
}

@Override
public final MutableQuadViewImpl fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace) {
fromVanilla(quad.getVertexData(), 0);
data[baseIndex + HEADER_BITS] = EncodingFormat.cullFace(0, cullFace);
cullFace(cullFace);
nominalFace(quad.getFace());
tintIndex(quad.getTintIndex());