From 01e41843872d9b95ee00d079d695e24b3c8def0c Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Sat, 8 Jun 2024 14:58:58 +0200 Subject: [PATCH] Revert "Optimize `canBeSeenThroughOtherBlock`" since it caused visual bugs. This reverts commit c405f336ddc7ecd0ab3bd0821d4dd10fccbcd4de. --- src/renderer/chunk_meshing.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer/chunk_meshing.zig b/src/renderer/chunk_meshing.zig index e79f7951b..728682fe7 100644 --- a/src/renderer/chunk_meshing.zig +++ b/src/renderer/chunk_meshing.zig @@ -696,11 +696,14 @@ pub const ChunkMesh = struct { } fn canBeSeenThroughOtherBlock(block: Block, other: Block, neighbor: u3) bool { - if(block.typ == 0) return false; - if(other.typ == 0) return true; - if(@as(u32, @bitCast(block)) == @as(u32, @bitCast(other))) return block.alwaysViewThrough(); - if(other.viewThrough()) return true; - return !models.models.items[blocks.meshes.model(other)].isNeighborOccluded[neighbor ^ 1]; // TODO: Should this also solve faces between partial blocks, like fences? + const rotatedModel = blocks.meshes.model(block); + const model = &models.models.items[rotatedModel]; + _ = model; // TODO: Check if the neighbor model occludes this one. (maybe not that relevant) + return block.typ != 0 and ( + other.typ == 0 + or (!std.meta.eql(block, other) and other.viewThrough()) or other.alwaysViewThrough() + or !models.models.items[blocks.meshes.model(other)].isNeighborOccluded[neighbor ^ 1] + ); } fn initLight(self: *ChunkMesh) void {