1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /*
- * =====================================================================================
- *
- * Filename: world.h
- *
- * Description: World manages and draws chunks
- *
- * Version: 1.0
- * Created: 04/03/2014 09:48:12 PM
- * Revision: none
- * Compiler: gcc
- *
- * Author: YOUR NAME (),
- * Organization:
- *
- * =====================================================================================
- */
-
- #pragma once
-
- #include "voxelutils.h"
- #include "voxelinfo.h"
- #include "voxelmath.h"
- #include "terraingen.h"
- #include "graphics/chunkmesh.h"
- #include "cuckoohash_map.hh"
-
- #include <unordered_map>
- #include <vector>
- #include <deque>
- #include <glm/glm.hpp>
-
- namespace vtk {
-
- class Chunk;
-
- class World {
- public:
- World();
- bool isVoxelSolid(const int& x, const int& y, const int& z);
-
- bool setVoxelType(const int& x, const int& y, const int& z, const unsigned& type, const bool& updateChunk = false);
-
- unsigned getVoxelType(const glm::ivec3& pos);
-
- Chunk* makeChunk(const int& x, const int& y, const int& z, bool insertAfter = true);
- bool generateChunk(const int& x, const int& y, const int& z);
- bool insertChunk(Chunk* chunk);
-
- Chunk* getChunk(const glm::ivec3& pos);
-
- void queueChunkUpdate(const int& x, const int& y, const int& z, const bool& back = false);
- void queueChunkUpdate(const glm::ivec3& pos, const bool& back = false);
-
- void queueChunkLoad(const glm::ivec3& pos);
-
- void draw();
- void update();
-
- void forceGlobalGeometryUpdate(); //Rebuilds all geometry. Don't do this.
-
- void queueChunkLoadsAroundPoint(const glm::vec3& point, const int& chunkRadius);
-
- //std::unordered_map<glm::ivec3, Chunk*, ivec3Hash> mChunks;
- cuckoohash_map<glm::ivec3, Chunk*, ivec3Hash> mChunks;
- std::unordered_map<glm::ivec3, ChunkMesh, ivec3Hash> mChunkMeshes;
- std::vector<iPos> chunkUpdateQueue;
- std::deque<glm::ivec3> mChunkUpdateQueue;
- std::deque<glm::ivec3> mChunkLoadQueue;
-
- unsigned chunkSize;
- float voxelSize;
-
- int modelMatUni;
-
- TerrainGen terrain;
- VoxelInfo voxelInfo;
- VoxelMath voxelMath;
- bool rebuildThreadActive;
- bool mLoadThreadActive;
- };
-
- }
|