Chunk.h 951 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef CHUNK_H
  2. #define CHUNK_H
  3. #include "common/block/Block.h"
  4. class Chunk
  5. {
  6. public:
  7. Chunk(int chunkX, int chunkZ);
  8. virtual ~Chunk();
  9. void setBlock(int x, int y, int z, const Block& block);
  10. const Block& getBlock(int x, int y, int z);
  11. int getChunkX() const;
  12. int getChunkZ() const;
  13. bool isDirty() const;
  14. bool isDirty(int index) const;
  15. void clearDirtyFlag(int index);
  16. // chunk constants
  17. static const int PARTION_HEIGHT = 16;
  18. static const int HEIGHT_PARTIONS = 16;
  19. static const int WIDTH = 16;
  20. static const int HEIGHT = PARTION_HEIGHT * HEIGHT_PARTIONS;
  21. static const int DEPTH = 16;
  22. static const int BITMASK_WIDTH = WIDTH - 1;
  23. static const int BITMASK_HEIGHT = HEIGHT - 1;
  24. static const int BITMASK_DEPTH = DEPTH - 1;
  25. private:
  26. int chunkX;
  27. int chunkZ;
  28. BlockId blocks[HEIGHT][WIDTH][DEPTH];
  29. bool dirty[HEIGHT_PARTIONS];
  30. };
  31. #endif