From 32878de5f38b548fe6351dfb962fe38a508b41ad Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 12 Mar 2022 00:50:46 +0300 Subject: [PATCH] Small render fixes --- src/voxels/ChunksController.cpp | 2 +- src/world_render.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/voxels/ChunksController.cpp b/src/voxels/ChunksController.cpp index d288181e..33888407 100644 --- a/src/voxels/ChunksController.cpp +++ b/src/voxels/ChunksController.cpp @@ -60,7 +60,7 @@ bool ChunksController::loadVisible(WorldFiles* worldFiles){ for (int oz = -1; oz <= 1; oz++){ for (int ox = -1; ox <= 1; ox++){ Chunk* other = chunks->getChunk(chunk->x+ox, chunk->y, chunk->z+oz); - if (other != nullptr) surrounding++; + if (other != nullptr && other->ready) surrounding++; } } chunk->surrounding = surrounding; diff --git a/src/world_render.h b/src/world_render.h index ef8344ab..d2909d9a 100644 --- a/src/world_render.h +++ b/src/world_render.h @@ -127,15 +127,14 @@ void draw_world(Camera* camera, Assets* assets, indices.push_back(i); } - std::sort(indices.begin(), indices.end(), chunks_comparator); - - float px = camera->position.x / (float)CHUNK_W; float pz = camera->position.z / (float)CHUNK_D; _camera_cx = px; _camera_cz = pz; + std::sort(indices.begin(), indices.end(), chunks_comparator); + for (size_t i = 0; i < indices.size(); i++){ draw_chunk(indices[i], camera, shader, occlusion); @@ -149,6 +148,8 @@ void draw_world(Camera* camera, Assets* assets, linesShader->use(); linesShader->uniformMatrix("u_projview", camera->getProjection()*camera->getView()); glLineWidth(2.0f); + lineBatch->line(camera->position.x, camera->position.y-0.5f, camera->position.z, camera->position.x+0.1f, camera->position.y-0.5f, camera->position.z, 1, 0, 0, 1); + lineBatch->line(camera->position.x, camera->position.y-0.5f, camera->position.z, camera->position.x, camera->position.y-0.5f, camera->position.z+0.1f, 0, 0, 1, 1); lineBatch->render(); }