123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef BLOCKSTORAGE_H
- #define BLOCKSTORAGE_H
- #include "common/Block.h"
- #include "memory/UniquePointer.h"
- #include "utils/BitArray.h"
- #include "utils/List.h"
- class BlockStorage final {
- int size;
- int height;
- int sizeMask;
- class Map {
- BitArray blocks;
- List<Block::Id> map;
- public:
- Map(int length, Block::Id id);
- Block::Id get(int index) const;
- void set(int index, Block::Id id);
- };
- List<UniquePointer<Map>> maps;
- static constexpr int SEGMENT_BITS = 4;
- static constexpr int SEGMENT_MASK = (1 << SEGMENT_BITS) - 1;
- public:
- static constexpr int SEGMENT = 1 << SEGMENT_BITS;
- BlockStorage(int sizeBits, int heightBits);
- Block::Id get(int x, int y, int z) const;
- void set(int x, int y, int z, Block::Id id);
- int getSize() const;
- int getHeight() const;
- };
- #endif
|