You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chunk.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "voxelutils.h"
  3. #include "chunkrenderer.h"
  4. #include "graphics/chunkmesh.h"
  5. #include "util/mobileatomic.h"
  6. #include <glm/glm.hpp>
  7. namespace vtk {
  8. class World;
  9. class HeightMap;
  10. class Chunk {
  11. friend class World;
  12. public:
  13. Chunk(World& world);
  14. bool isLoaded();
  15. bool isVoxelSolid(const int& x, const int& y, const int& z); //Is the voxel not a transparent type?
  16. void setVoxelType(const int& x, const int& y, const int& z, const unsigned& type, const bool& update = false);
  17. unsigned getVoxelType(const unsigned& x, const unsigned& y, const unsigned& z);
  18. glm::ivec3 getWorldCoords(const int& x, const int& y, const int& z);
  19. unsigned getLightLevel(const glm::ivec3& pos);
  20. unsigned getLightPacked(const glm::ivec3& pos);
  21. HeightMap* getHeightMap();
  22. void setPos(const glm::ivec3& pos);
  23. glm::ivec3 getPos();
  24. World& getWorld();
  25. ChunkRenderer renderer;
  26. protected:
  27. void setQueuedForMeshRebuild(const bool& rebuild = true);
  28. bool isQueuedForMeshRebuild();
  29. std::array<util::MobileAtomic<unsigned>, 4096> mData;
  30. //std::array<unsigned, 4096> voxels;
  31. World& mLinkedWorld;
  32. glm::ivec3 mPos;
  33. std::atomic<bool> mLoaded;
  34. std::atomic<bool> mQueuedForMeshRebuild;
  35. };
  36. }