Chunk.h 929 B

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