1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Break liquid reflow scan early for all-air blocks (#15975)

Avoid scanning the a newly loaded block if it is all air and no liquid is flowing from above.
This commit is contained in:
lhofhansl 2025-04-05 08:01:39 -10:00 committed by GitHub
parent 52b974184d
commit 6a71095655
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -121,41 +121,48 @@ void ReflowScan::scanColumn(int x, int z)
bool was_checked = false; bool was_checked = false;
bool was_pushed = false; bool was_pushed = false;
// Scan through the whole block // if there is no liquid above and the current block is air
for (s16 y = MAP_BLOCKSIZE - 1; y >= 0; y--) { // we can skip scanning the block
MapNode node = block->getNodeNoCheck(dx, y, dz); if (!was_liquid && block->isAir()) {
const ContentFeatures &f = m_ndef->get(node); // continue after the block with air
bool is_ignore = node.getContent() == CONTENT_IGNORE; was_ignore = false;
bool is_liquid = f.isLiquid(); } else {
// Scan through the whole block
for (s16 y = MAP_BLOCKSIZE - 1; y >= 0; y--) {
MapNode node = block->getNodeNoCheck(dx, y, dz);
const ContentFeatures &f = m_ndef->get(node);
bool is_ignore = node.getContent() == CONTENT_IGNORE;
bool is_liquid = f.isLiquid();
if (is_ignore || was_ignore || is_liquid == was_liquid) { if (is_ignore || was_ignore || is_liquid == was_liquid) {
// Neither topmost node of liquid column nor topmost node below column // Neither topmost node of liquid column nor topmost node below column
was_checked = false; was_checked = false;
was_pushed = false; was_pushed = false;
} else if (is_liquid) { } else if (is_liquid) {
// This is the topmost node in the column // This is the topmost node in the column
bool is_pushed = false; bool is_pushed = false;
if (f.liquid_type == LIQUID_FLOWING || if (f.liquid_type == LIQUID_FLOWING ||
isLiquidHorizontallyFlowable(x, y, z)) { isLiquidHorizontallyFlowable(x, y, z)) {
m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, y, z)); m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, y, z));
is_pushed = true; is_pushed = true;
} }
// Remember waschecked and waspushed to avoid repeated // Remember waschecked and waspushed to avoid repeated
// checks/pushes in case the column consists of only this node // checks/pushes in case the column consists of only this node
was_checked = true; was_checked = true;
was_pushed = is_pushed; was_pushed = is_pushed;
} else { } else {
// This is the topmost node below a liquid column // This is the topmost node below a liquid column
if (!was_pushed && (f.floodable || if (!was_pushed && (f.floodable ||
(!was_checked && isLiquidHorizontallyFlowable(x, y + 1, z)))) { (!was_checked && isLiquidHorizontallyFlowable(x, y + 1, z)))) {
// Activate the lowest node in the column which is one // Activate the lowest node in the column which is one
// node above this one // node above this one
m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, y + 1, z)); m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, y + 1, z));
}
} }
was_liquid = is_liquid;
was_ignore = is_ignore;
} }
was_liquid = is_liquid;
was_ignore = is_ignore;
} }
// Check the node below the current block // Check the node below the current block