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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <glm/glm.hpp>
  27. namespace vtk {
  28. class Chunk;
  29. class World {
  30. public:
  31. World();
  32. bool isVoxelSolid(const int& x, const int& y, const int& z);
  33. bool setVoxelType(const int& x, const int& y, const int& z, const unsigned& type, const bool& updateChunk = false);
  34. unsigned getVoxelType(const glm::ivec3& pos);
  35. bool makeChunk(const int& x, const int& y, const int& z);
  36. bool generateChunk(const int& x, const int& y, const int& z);
  37. Chunk* getChunk(const glm::ivec3& pos);
  38. void queueChunkUpdate(const int& x, const int& y, const int& z);
  39. void queueChunkUpdate(const iPos& pos);
  40. void draw();
  41. void update();
  42. void forceGlobalGeometryUpdate(); //Rebuilds all geometry. Don't do this.
  43. std::unordered_map<iPos, Chunk*, iPosHash, iPosEqual> chunks;
  44. std::unordered_map<glm::ivec3, ChunkMesh, ivec3Hash> mChunkMeshes;
  45. std::vector<iPos> chunkUpdateQueue;
  46. std::vector<glm::ivec3> mChunkGeometryUpdateQueue;
  47. unsigned chunkSize;
  48. float voxelSize;
  49. int modelMatUni;
  50. TerrainGen terrain;
  51. VoxelInfo voxelInfo;
  52. VoxelMath voxelMath;
  53. };
  54. }