BlockStorage.h 633 B

123456789101112131415161718192021222324252627282930
  1. #ifndef BLOCKSTORAGE_H
  2. #define BLOCKSTORAGE_H
  3. #include "common/world/BlockMap.h"
  4. #include "memory/UniquePointer.h"
  5. #include "utils/List.h"
  6. class BlockStorage final {
  7. int size;
  8. int height;
  9. int sizeMask;
  10. List<UniquePointer<BlockMap>> maps;
  11. static constexpr int SEGMENT_BITS = 4;
  12. static constexpr int SEGMENT_MASK = (1 << SEGMENT_BITS) - 1;
  13. public:
  14. static constexpr int SEGMENT = 1 << SEGMENT_BITS;
  15. BlockStorage(int sizeBits, int heightBits);
  16. BlockId get(int x, int y, int z) const;
  17. void set(int x, int y, int z, BlockId id);
  18. int getSize() const;
  19. int getHeight() const;
  20. };
  21. #endif