chunkmgr: avoid call of chunkmesh default ctor
parent
93adf73777
commit
a5ddb0e37f
|
@ -13,7 +13,6 @@ class ChunkMesh
|
|||
{
|
||||
|
||||
public:
|
||||
ChunkMesh();
|
||||
ChunkMesh(Chunk::Chunk *c);
|
||||
void mesh();
|
||||
void draw();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
std::unordered_map<std::uint32_t, ChunkMesh> chunks{};
|
||||
std::unordered_map<std::uint32_t, ChunkMesh> chunks;
|
||||
|
||||
namespace chunkmanager
|
||||
{
|
||||
|
@ -86,16 +86,14 @@ namespace chunkmanager
|
|||
// std::cout << "Checking" << i << ", " << j << ", " << k <<std::endl;
|
||||
if (chunks.find(index) == chunks.end())
|
||||
{
|
||||
ChunkMesh c(new Chunk::Chunk(glm::vec3(i, j, k)));
|
||||
chunks[index] = c;
|
||||
|
||||
generateChunk(chunks[index].chunk);
|
||||
chunks[index].mesh();
|
||||
chunks.insert(std::make_pair(index, ChunkMesh(new Chunk::Chunk(glm::vec3(i, j, k)))));
|
||||
generateChunk(chunks.at(index) .chunk);
|
||||
chunks.at(index).mesh();
|
||||
|
||||
// std::cout << "Creating new chunk" << i << ", " << j << ", " << k <<std::endl;
|
||||
}
|
||||
|
||||
chunks[index].draw();
|
||||
else
|
||||
chunks.at(index).draw();
|
||||
}
|
||||
|
||||
void destroy()
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
#include "spacefilling.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
ChunkMesh::ChunkMesh()
|
||||
{
|
||||
// std::cout << "CHUNK MESH " << std::endl;
|
||||
ChunkMesh::~ChunkMesh(){
|
||||
// std::cout << "Destroy" << this->chunk << std::endl;
|
||||
// if(this->chunk != nullptr) delete this->chunk;
|
||||
// this->chunk = nullptr;
|
||||
// delete[] (this->theShader);
|
||||
}
|
||||
|
||||
ChunkMesh::ChunkMesh(Chunk::Chunk *c)
|
||||
|
@ -30,8 +32,6 @@ ChunkMesh::ChunkMesh(Chunk::Chunk *c)
|
|||
void ChunkMesh::mesh()
|
||||
{
|
||||
|
||||
if (!(this->chunk))
|
||||
return;
|
||||
/*
|
||||
* Taking inspiration from 0fps and the jme3 porting at
|
||||
* https://github.com/roboleary/GreedyMesh/blob/master/src/mygame/Main.java
|
||||
|
@ -227,8 +227,6 @@ void ChunkMesh::mesh()
|
|||
|
||||
void ChunkMesh::draw()
|
||||
{
|
||||
if (!(this->chunk))
|
||||
return;
|
||||
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // wireframe mode
|
||||
|
||||
|
|
Loading…
Reference in New Issue