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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, const bool& back = false);
  40. void queueChunkUpdate(const glm::ivec3& pos, const bool& back = false);
  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. unsigned chunkSize;
  49. float voxelSize;
  50. int modelMatUni;
  51. TerrainGen terrain;
  52. VoxelInfo voxelInfo;
  53. VoxelMath voxelMath;
  54. bool rebuildThreadActive;
  55. };
  56. }