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.

heightmap.h 751B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <glm/glm.hpp>
  3. #include <array>
  4. #include <utility>
  5. #include "concurrentqueue.h"
  6. #include "util/mobileatomic.h"
  7. namespace vtk {
  8. class World;
  9. class HeightMap {
  10. public:
  11. HeightMap(const glm::ivec2& pos, World& world);
  12. glm::ivec2 getPos();
  13. int getHeight(const glm::ivec2& pos);
  14. bool pushUpdate(const glm::ivec3& pos, const bool& destroyed);
  15. void blockHeight(const glm::ivec3& pos);
  16. void unblockHeight(const glm::ivec3& pos);
  17. void flushUpdates(); // called from worker thread
  18. protected:
  19. void setHeight(const::glm::ivec3& pos);
  20. World& mWorld;
  21. glm::ivec2 mPos;
  22. std::array<util::MobileAtomic<int>, (16*16)> mHeights; //stores 16*16 heightmap
  23. moodycamel::ConcurrentQueue<std::pair<glm::ivec3, bool>> mUpdateQueue;
  24. };
  25. }