From 9714cdcf4ba51b44cca72e133ec5ef2a3c9f50f6 Mon Sep 17 00:00:00 2001 From: MillersMan Date: Sun, 27 Nov 2016 21:51:40 +0100 Subject: Liquids: Update flow on block load When loading a block add liquid-nodes that might flow away or spread to neighbours to the transforming_liquid queue. --- src/reflowscan.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/reflowscan.h (limited to 'src/reflowscan.h') diff --git a/src/reflowscan.h b/src/reflowscan.h new file mode 100644 index 000000000..a6d289ad5 --- /dev/null +++ b/src/reflowscan.h @@ -0,0 +1,50 @@ +/* +Minetest +Copyright (C) 2016 MillersMan + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef REFLOWSCAN_H +#define REFLOWSCAN_H + +#include "util/container.h" +#include "irrlichttypes_bloated.h" + +class INodeDefManager; +class Map; +class MapBlock; + +class ReflowScan { +public: + ReflowScan(Map *map, INodeDefManager *ndef); + void scan(MapBlock *block, UniqueQueue *liquid_queue); + +private: + MapBlock *lookupBlock(int x, int y, int z); + bool isLiquidFlowableTo(int x, int y, int z); + bool isLiquidHorizontallyFlowable(int x, int y, int z); + void scanColumn(int x, int z); + +private: + Map *m_map; + INodeDefManager *m_ndef; + v3s16 m_block_pos, m_rel_block_pos; + UniqueQueue *m_liquid_queue; + MapBlock *m_lookup[3 * 3 * 3]; + u32 m_lookup_state_bitset; +}; + +#endif // REFLOWSCAN_H -- cgit v1.2.3