From 4ada24e0d5ce29d4369de71674e8e09a101e3cd6 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Thu, 15 Jun 2023 10:10:49 +0200 Subject: [PATCH] chunkmesher: check for NULLBLK to avoid holes at chunkborders --- src/chunkmesher.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/chunkmesher.cpp b/src/chunkmesher.cpp index f0fccdb..3fcc324 100755 --- a/src/chunkmesher.cpp +++ b/src/chunkmesher.cpp @@ -124,9 +124,13 @@ void mesh(Chunk::Chunk* chunk) } // Compute the mask - mask[n++] = b1 != Block::NULLBLK && b2 != Block::NULLBLK && b1 == b2 ? Block::NULLBLK - : backFace ? b1 == Block::AIR ? b2 : Block::NULLBLK - : b2 == Block::AIR ? b1 : Block::NULLBLK; + // Checking if b1==b2 is needed to generate a single quad + // The else case provides face culling for adjacent solid faces + // Checking for NULLBLK avoids creating empty faces if nearby chunk was not + // yet generated + mask[n++] = b1 == b2 ? Block::NULLBLK + : backFace ? b1 == Block::NULLBLK || b1 == Block::AIR ? b2 : Block::NULLBLK + : b2 == Block::NULLBLK || b2 == Block::AIR ? b1 : Block::NULLBLK; } }