btuhs
This commit is contained in:
@@ -23,7 +23,6 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class Frustrum {
|
||||
|
||||
@@ -21,6 +21,7 @@ std::shared_ptr<CBlockDictionary> CBlockDictionary::GetInstance() {
|
||||
|
||||
void CBlockDictionary::Build() {
|
||||
|
||||
// Order matters !
|
||||
RegisterTexture("stone.png");
|
||||
RegisterTexture("dirt.png");
|
||||
RegisterTexture("grass_side.png");
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
#ifndef MINECRAFT_WORLD_GENERATOR_CHUNKGENERATOR_H_
|
||||
#define MINECRAFT_WORLD_GENERATOR_CHUNKGENERATOR_H_
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
28
src/world/generator/chunkmanager.hpp
Normal file
28
src/world/generator/chunkmanager.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef MINECRAFT_WORLD_GENERATOR_CUNKMANAGER_H_
|
||||
#define MINECRAFT_WORLD_GENERATOR_CUNKMANAGER_H_
|
||||
|
||||
#include "../../common.hpp"
|
||||
|
||||
|
||||
class Frustrum;
|
||||
|
||||
class ChunkManager {
|
||||
public:
|
||||
|
||||
// Instatntiated
|
||||
ChunkManager();
|
||||
|
||||
void Update();
|
||||
|
||||
void Play();
|
||||
void Pause();
|
||||
|
||||
void LoadChunksAroundWorldPoint(glm::vec3 worldPoint);
|
||||
|
||||
|
||||
|
||||
void CullFrustrumFromRenderQueue();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -32,12 +32,12 @@ void World::LoadWorld() {
|
||||
m_noiseGenerator->SetFractalOctaves(5);
|
||||
|
||||
// Generate a 54x54 chunk world
|
||||
// for (int x = -4; x < 50; x++)
|
||||
// for (int y = -50; y < 4; y++) {
|
||||
for (int x = -4; x < 50; x++)
|
||||
for (int y = -50; y < 4; y++) {
|
||||
|
||||
// m_chunkLoaderQueue.push({ x, y });
|
||||
m_chunkLoaderQueue.push({ x, y });
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// Spawn generator threads
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -103,20 +103,20 @@ std::vector<std::shared_ptr<Chunk>> World::GetRenderableChunks() {
|
||||
|
||||
void World::Update(std::shared_ptr<Entity> player) {
|
||||
|
||||
glm::vec2 inChunk = GetChunk(player->Position);
|
||||
// glm::vec2 inChunk = GetChunk(player->Position);
|
||||
|
||||
if (m_chunks.find(inChunk) == m_chunks.end()) {
|
||||
// if (m_chunks.find(inChunk) == m_chunks.end()) {
|
||||
|
||||
m_chunkLoderMutex.lock();
|
||||
// m_chunkLoderMutex.lock();
|
||||
|
||||
m_chunkLoaderQueue.push(inChunk);
|
||||
// m_chunkLoaderQueue.push(inChunk);
|
||||
|
||||
m_chunkLoderMutex.unlock();
|
||||
// m_chunkLoderMutex.unlock();
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
std::cout << "Position: " << player->Position.x << ":" << player->Position.y << ":" << player->Position.z << std::endl;
|
||||
std::cout << "Chunk: " << inChunk.x << ":" << inChunk.y << std::endl << std::endl;
|
||||
// std::cout << "Position: " << player->Position.x << ":" << player->Position.y << ":" << player->Position.z << std::endl;
|
||||
// std::cout << "Chunk: " << inChunk.x << ":" << inChunk.y << std::endl << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "../renderer/camera.hpp"
|
||||
|
||||
#include "generator/chunkmanager.hpp"
|
||||
#include "chunk/chunk.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
@@ -23,7 +24,6 @@ public:
|
||||
// Default constructor
|
||||
World();
|
||||
|
||||
|
||||
// Preps the render threads and loads all of the shaders
|
||||
void LoadWorld();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user