reflowscan.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef REFLOWSCAN_H
  17. #define REFLOWSCAN_H
  18. #include "util/container.h"
  19. #include "irrlichttypes_bloated.h"
  20. class INodeDefManager;
  21. class Map;
  22. class MapBlock;
  23. class ReflowScan {
  24. public:
  25. ReflowScan(Map *map, INodeDefManager *ndef);
  26. void scan(MapBlock *block, UniqueQueue<v3s16> *liquid_queue);
  27. private:
  28. MapBlock *lookupBlock(int x, int y, int z);
  29. bool isLiquidFlowableTo(int x, int y, int z);
  30. bool isLiquidHorizontallyFlowable(int x, int y, int z);
  31. void scanColumn(int x, int z);
  32. private:
  33. Map *m_map = nullptr;
  34. INodeDefManager *m_ndef = nullptr;
  35. v3s16 m_block_pos, m_rel_block_pos;
  36. UniqueQueue<v3s16> *m_liquid_queue = nullptr;
  37. MapBlock *m_lookup[3 * 3 * 3];
  38. u32 m_lookup_state_bitset;
  39. };
  40. #endif // REFLOWSCAN_H