From e358832f2f869f35adc0efaffe1177acea42526b Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Mon, 9 Oct 2023 23:02:54 +0200 Subject: [PATCH] Fix an oversight in the last commit that caused face duplication at chunk borders. --- assets/cubyz/shaders/chunks/chunk_fragment.fs | 1 - src/chunk.zig | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/cubyz/shaders/chunks/chunk_fragment.fs b/assets/cubyz/shaders/chunks/chunk_fragment.fs index 000daee03..97278ff90 100644 --- a/assets/cubyz/shaders/chunks/chunk_fragment.fs +++ b/assets/cubyz/shaders/chunks/chunk_fragment.fs @@ -86,5 +86,4 @@ void main() { fragColor.a = 1; fragColor.rgb += texture(emissionSampler, textureCoords).rgb; - // TODO: Update the depth. } diff --git a/src/chunk.zig b/src/chunk.zig index 63af90669..acb6abb41 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -928,6 +928,8 @@ pub const meshing = struct { if(neighborMesh.generated) { var additionalNeighborFacesOpaque = std.ArrayList(FaceData).init(main.threadAllocator); defer additionalNeighborFacesOpaque.deinit(); + var additionalNeighborFacesVoxel = std.ArrayList(FaceData).init(main.threadAllocator); + defer additionalNeighborFacesVoxel.deinit(); var additionalNeighborFacesTransparent = std.ArrayList(FaceData).init(main.threadAllocator); defer additionalNeighborFacesTransparent.deinit(); var x3: u8 = if(neighbor & 1 == 0) @intCast(chunkMask) else 0; @@ -963,7 +965,11 @@ pub const meshing = struct { } try additionalNeighborFacesTransparent.append(constructFaceData(block, neighbor, otherX, otherY, otherZ, false)); } else { - try additionalNeighborFacesOpaque.append(constructFaceData(block, neighbor, otherX, otherY, otherZ, false)); + if(blocks.meshes.model(block).modelIndex == 0) { + try additionalNeighborFacesOpaque.append(constructFaceData(block, neighbor, otherX, otherY, otherZ, false)); + } else { + try additionalNeighborFacesVoxel.append(constructFaceData(block, neighbor, otherX, otherY, otherZ, false)); + } } } if(canBeSeenThroughOtherBlock(otherBlock, block, neighbor ^ 1)) { @@ -983,7 +989,7 @@ pub const meshing = struct { } } try neighborMesh.opaqueMesh.replaceNeighbors(neighbor, additionalNeighborFacesOpaque.items); - try neighborMesh.voxelMesh.replaceNeighbors(neighbor, additionalNeighborFacesOpaque.items); + try neighborMesh.voxelMesh.replaceNeighbors(neighbor, additionalNeighborFacesVoxel.items); try neighborMesh.transparentMesh.replaceNeighbors(neighbor, additionalNeighborFacesTransparent.items); continue; }