Chunk.h 675 B

1234567891011121314151617181920212223242526272829
  1. #ifndef CHUNK_H
  2. #define CHUNK_H
  3. #include "common/block/Block.h"
  4. #include "common/utils/Types.h"
  5. class Chunk final
  6. {
  7. public:
  8. Chunk();
  9. void setBlock(u32 x, u32 y, u32 z, const Block& block);
  10. const Block& getBlock(u32 x, u32 y, u32 z) const;
  11. static const u32 CHUNK_BIT_SIZE = 4;
  12. private:
  13. static const u32 CHUNK_PARTION_SIZE = 1 << CHUNK_BIT_SIZE;
  14. static const u32 HEIGHT_PARTIONS = 16;
  15. static const u32 HEIGHT = CHUNK_PARTION_SIZE * HEIGHT_PARTIONS;
  16. static const u32 BITMASK = CHUNK_PARTION_SIZE - 1;
  17. static const u32 BITMASK_HEIGHT = HEIGHT - 1;
  18. u16 blocks[HEIGHT][CHUNK_PARTION_SIZE][CHUNK_PARTION_SIZE];
  19. };
  20. #endif