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.

world.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: world.h
  5. *
  6. * Description: World manages and draws chunks
  7. *
  8. * Version: 1.0
  9. * Created: 04/03/2014 09:48:12 PM
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: YOUR NAME (),
  14. * Organization:
  15. *
  16. * =====================================================================================
  17. */
  18. #pragma once
  19. #include "voxelutils.h"
  20. #include "voxelinfo.h"
  21. #include "voxelmath.h"
  22. #include "terraingen.h"
  23. #include "graphics/chunkmesh.h"
  24. #include <unordered_map>
  25. #include <vector>
  26. #include <deque>
  27. #include <glm/glm.hpp>
  28. namespace vtk {
  29. class Chunk;
  30. class World {
  31. public:
  32. World();
  33. bool isVoxelSolid(const int& x, const int& y, const int& z);
  34. bool setVoxelType(const int& x, const int& y, const int& z, const unsigned& type, const bool& updateChunk = false);
  35. unsigned getVoxelType(const glm::ivec3& pos);
  36. bool makeChunk(const int& x, const int& y, const int& z);
  37. bool generateChunk(const int& x, const int& y, const int& z);
  38. Chunk* getChunk(const glm::ivec3& pos);
  39. void queueChunkUpdate(const int& x, const int& y, const int& z);
  40. void queueChunkUpdate(const glm::ivec3& pos);
  41. void draw();
  42. void update();
  43. void forceGlobalGeometryUpdate(); //Rebuilds all geometry. Don't do this.
  44. std::unordered_map<glm::ivec3, Chunk*, ivec3Hash> mChunks;
  45. std::unordered_map<glm::ivec3, ChunkMesh, ivec3Hash> mChunkMeshes;
  46. std::vector<iPos> chunkUpdateQueue;
  47. std::deque<glm::ivec3> mChunkUpdateQueue;
  48. std::vector<glm::ivec3> mChunkGeometryUpdateQueue;
  49. unsigned chunkSize;
  50. float voxelSize;
  51. int modelMatUni;
  52. TerrainGen terrain;
  53. VoxelInfo voxelInfo;
  54. VoxelMath voxelMath;
  55. bool rebuildThreadActive;
  56. };
  57. }