reflowscan.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. Minetest
  3. Copyright (C) 2016 MillersMan <millersman@users.noreply.github.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include "util/container.h"
  18. #include "irrlichttypes_bloated.h"
  19. class NodeDefManager;
  20. class Map;
  21. class MapBlock;
  22. class ReflowScan {
  23. public:
  24. ReflowScan(Map *map, const NodeDefManager *ndef);
  25. void scan(MapBlock *block, UniqueQueue<v3s16> *liquid_queue);
  26. private:
  27. MapBlock *lookupBlock(int x, int y, int z);
  28. bool isLiquidFlowableTo(int x, int y, int z);
  29. bool isLiquidHorizontallyFlowable(int x, int y, int z);
  30. void scanColumn(int x, int z);
  31. private:
  32. Map *m_map = nullptr;
  33. const NodeDefManager *m_ndef = nullptr;
  34. v3s16 m_block_pos, m_rel_block_pos;
  35. UniqueQueue<v3s16> *m_liquid_queue = nullptr;
  36. MapBlock *m_lookup[3 * 3 * 3];
  37. u32 m_lookup_state_bitset;
  38. };