This commit is contained in:
Ben
2019-11-18 02:12:31 +00:00
parent b2ac1f3757
commit 7e859edd8e
7 changed files with 47 additions and 15 deletions

View File

@@ -26,7 +26,7 @@ float EntityCollider::m_xDepth(ColliderBox a, ColliderBox b) {
float EntityCollider::m_yDepth(ColliderBox a, ColliderBox b) {
}

View File

@@ -22,7 +22,6 @@ class FrustrumPlane {
public:
};

View File

@@ -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");

View File

@@ -1,2 +1,6 @@
#ifndef MINECRAFT_WORLD_GENERATOR_CHUNKGENERATOR_H_
#define MINECRAFT_WORLD_GENERATOR_CHUNKGENERATOR_H_
#endif

View 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

View File

@@ -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;
}

View File

@@ -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();