Skip to content

Commit

Permalink
Prevent sodium from culling copycat quads after custom culling has al…
Browse files Browse the repository at this point in the history
…ready been done, fixes #112
  • Loading branch information
hlysine committed Jul 21, 2024
1 parent cc9ccc2 commit 924fef1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, Block
CopycatRenderContextFabric copycatContext = new CopycatRenderContextFabric(quads, emitter, entry.key());
entry.part().emitCopycatQuads(entry.key(), state, copycatContext, material);

context.pushTransform(quad -> !occlusionData.isOccluded(quad.cullFace()));
context.pushTransform(quad -> {
if (occlusionData.isOccluded(quad.cullFace()))
return false;
// Set cull face to null after culling to avoid interference from sodium
quad.cullFace(null);
return true;
});
meshBuilder.build().outputTo(context.getEmitter());
context.popTransform();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static MutableQuad getMutableQuad(int[] vertexData, @Nullable Direction c

public static class CopycatBakedQuad extends BakedQuad {
@Nullable
public final Direction cullFace;
public Direction cullFace;
public final String property;

public CopycatBakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, @Nullable Direction cullFace, String property) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ private void gatherOcclusionData(BlockAndTintGetter world, BlockPos pos, BlockSt
if (occlusionData != null && occlusionData.isOccluded(croppedQuad.cullFace))
continue;

// Copycat quads are already culled. Set it to null to avoid interference from sodium
if (entry.type().useCopycatLogic())
croppedQuad.cullFace = null;

allQuads.add(croppedQuad);
}
}
Expand Down

0 comments on commit 924fef1

Please sign in to comment.