From 3f801bc096077a91094087fab4a4557198429851 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 27 Sep 2022 01:27:47 +0200 Subject: [PATCH] Fix liquid drawtype faces sometimes not rendering (#12807) Co-authored-by: SmallJoker --- src/client/mapblock_mesh.cpp | 6 +++--- src/nodedef.cpp | 2 +- src/nodedef.h | 13 ++++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index d05a786a6..5036f8bd6 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -651,7 +651,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent, const ContentFeatures &f2 = ndef->get(m2); // Contents don't differ for different forms of same liquid - if (f1.sameLiquid(f2)) + if (f1.sameLiquidRender(f2)) return 0; u8 c1 = f1.solidness; @@ -668,9 +668,9 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent, if (c1 == c2) { *equivalent = true; // If same solidness, liquid takes precense - if (f1.isLiquid()) + if (f1.isLiquidRender()) return 1; - if (f2.isLiquid()) + if (f2.isLiquidRender()) return 2; } diff --git a/src/nodedef.cpp b/src/nodedef.cpp index f42231736..5707d31a0 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -1681,7 +1681,7 @@ static void removeDupes(std::vector &list) void NodeDefManager::resolveCrossrefs() { for (ContentFeatures &f : m_content_features) { - if (f.liquid_type != LIQUID_NONE || f.drawtype == NDT_LIQUID || f.drawtype == NDT_FLOWINGLIQUID) { + if (f.isLiquid() || f.isLiquidRender()) { f.liquid_alternative_flowing_id = getId(f.liquid_alternative_flowing); f.liquid_alternative_source_id = getId(f.liquid_alternative_source); continue; diff --git a/src/nodedef.h b/src/nodedef.h index b63748e44..8f0d0e9e8 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -493,9 +493,16 @@ struct ContentFeatures bool isLiquid() const{ return (liquid_type != LIQUID_NONE); } - bool sameLiquid(const ContentFeatures &f) const{ - if(!isLiquid() || !f.isLiquid()) return false; - return (liquid_alternative_flowing_id == f.liquid_alternative_flowing_id); + + bool isLiquidRender() const { + return (drawtype == NDT_LIQUID || drawtype == NDT_FLOWINGLIQUID); + } + + bool sameLiquidRender(const ContentFeatures &f) const { + if (!isLiquidRender() || !f.isLiquidRender()) + return false; + return liquid_alternative_flowing_id == f.liquid_alternative_flowing_id && + liquid_alternative_source_id == f.liquid_alternative_source_id; } bool lightingEquivalent(const ContentFeatures &other) const {