From 5fea779e3716c6e58b6f4789f8c839def33d42e6 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Sat, 30 Mar 2024 22:54:48 +0100 Subject: [PATCH] Undo the performance regression of the previous commit by adding a special case for air blocks. --- src/renderer/lighting.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/lighting.zig b/src/renderer/lighting.zig index 15320f59..c172b3a8 100644 --- a/src/renderer/lighting.zig +++ b/src/renderer/lighting.zig @@ -75,6 +75,7 @@ pub const ChannelChunk = struct { } fn calculateIncomingOcclusion(result: *[3]u8, block: blocks.Block, voxelSize: u31, neighbor: usize) void { + if(block.typ == 0) return; if(main.models.models.items[blocks.meshes.model(block)].isNeighborOccluded[neighbor]) { var absorption: [3]u8 = extractColor(block.absorption()); absorption[0] *|= @intCast(voxelSize); @@ -87,6 +88,7 @@ pub const ChannelChunk = struct { } fn calculateOutgoingOcclusion(result: *[3]u8, block: blocks.Block, voxelSize: u31, neighbor: usize) void { + if(block.typ == 0) return; const model = &main.models.models.items[blocks.meshes.model(block)]; if(model.isNeighborOccluded[neighbor] and !model.isNeighborOccluded[neighbor ^ 1]) { // Avoid calculating the absorption twice. var absorption: [3]u8 = extractColor(block.absorption());