Added chunks counter to debug info screen
This commit is contained in:
parent
265ebc0927
commit
191b88192b
@ -334,7 +334,7 @@ int main() {
|
||||
chunksController.loadVisible(wfile);
|
||||
|
||||
draw_world(player, camera, assets, chunks, occlusion);
|
||||
draw_hud(player, assets, devdata, fps);
|
||||
draw_hud(player, assets, chunks, devdata, fps);
|
||||
|
||||
Window::swapBuffers();
|
||||
Events::pullEvents();
|
||||
|
||||
@ -23,6 +23,7 @@ Chunks::Chunks(int w, int h, int d, int ox, int oy, int oz) : w(w), h(h), d(d),
|
||||
chunks[i] = nullptr;
|
||||
meshes[i] = nullptr;
|
||||
}
|
||||
chunksCount = 0;
|
||||
}
|
||||
|
||||
Chunks::~Chunks(){
|
||||
@ -281,6 +282,7 @@ void Chunks::translate(WorldFiles* worldFiles, int dx, int dy, int dz){
|
||||
worldFiles->put((const char*)chunk->voxels, chunk->x, chunk->z);
|
||||
chunk->decref();
|
||||
delete mesh;
|
||||
chunksCount--;
|
||||
continue;
|
||||
}
|
||||
meshesSecond[(ny * d + nz) * w + nx] = mesh;
|
||||
@ -317,6 +319,7 @@ bool Chunks::putChunk(Chunk* chunk) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= w || y >= h || z >= d)
|
||||
return false;
|
||||
chunks[(y * d + z) * w + x] = chunk;
|
||||
chunksCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -329,4 +332,5 @@ void Chunks::clear(bool freeMemory){
|
||||
chunks[i] = nullptr;
|
||||
meshes[i] = nullptr;
|
||||
}
|
||||
chunksCount = 0;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ public:
|
||||
Mesh** meshes;
|
||||
Mesh** meshesSecond;
|
||||
size_t volume;
|
||||
size_t chunksCount;
|
||||
unsigned int w,h,d;
|
||||
int ox,oy,oz;
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ bool ChunksController::loadVisible(WorldFiles* worldFiles){
|
||||
if (worldFiles->getChunk(chunk->x, chunk->z, (char*)chunk->voxels))
|
||||
chunk->loaded = true;
|
||||
|
||||
chunks->chunks[index] = chunk;
|
||||
chunks->putChunk(chunk);
|
||||
|
||||
Chunk* closes[27];
|
||||
for (int i = 0; i < 27; i++)
|
||||
|
||||
@ -110,7 +110,7 @@ bool chunks_comparator(size_t i, size_t j) {
|
||||
}
|
||||
|
||||
|
||||
void draw_hud(Player* player, Assets* assets, bool devdata, int fps){
|
||||
void draw_hud(Player* player, Assets* assets, Chunks* chunks, bool devdata, int fps){
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
Shader* uishader = assets->getShader("ui");
|
||||
@ -122,11 +122,11 @@ void draw_hud(Player* player, Assets* assets, bool devdata, int fps){
|
||||
batch->begin();
|
||||
batch->texture(font->texture);
|
||||
if (devdata){
|
||||
font->drawWithShadow(batch, "devdata does not exist", 16, 16);
|
||||
font->drawWithShadow(batch, "chunks: "+std::to_string(chunks->chunksCount), 16, 16);
|
||||
font->drawWithShadow(batch, std::to_string((int)player->camera->position.x), 10, 30);
|
||||
font->drawWithShadow(batch, std::to_string((int)player->camera->position.y), 50, 30);
|
||||
font->drawWithShadow(batch, std::to_string((int)player->camera->position.z), 90, 30);
|
||||
font->drawWithShadow(batch, "fps:", 16, 42);
|
||||
font->drawWithShadow(batch, "fps: ", 16, 42);
|
||||
font->drawWithShadow(batch, std::to_string(fps), 40, 42);
|
||||
}
|
||||
batch->render();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user