summaryrefslogtreecommitdiff
path: root/src/reflowscan.h
diff options
context:
space:
mode:
authorMillersMan <millersman@users.noreply.github.com>2016-11-27 21:51:40 +0100
committerparamat <mat.gregory@virginmedia.com>2016-12-07 04:06:00 +0000
commit9714cdcf4ba51b44cca72e133ec5ef2a3c9f50f6 (patch)
treec3b4e4d0c6d60924f06d44a0395730f872763633 /src/reflowscan.h
parentcc36f5e99ae46cf2fd370dde8311f139169a4c43 (diff)
downloadminetest-9714cdcf4ba51b44cca72e133ec5ef2a3c9f50f6.tar.gz
minetest-9714cdcf4ba51b44cca72e133ec5ef2a3c9f50f6.tar.bz2
minetest-9714cdcf4ba51b44cca72e133ec5ef2a3c9f50f6.zip
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.
Diffstat (limited to 'src/reflowscan.h')
-rw-r--r--src/reflowscan.h50
1 files changed, 50 insertions, 0 deletions
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 <millersman@users.noreply.github.com>
+
+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<v3s16> *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<v3s16> *m_liquid_queue;
+ MapBlock *m_lookup[3 * 3 * 3];
+ u32 m_lookup_state_bitset;
+};
+
+#endif // REFLOWSCAN_H