Skip to content

Commit

Permalink
fix chunk mesh refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Jan 11, 2025
1 parent 7b96284 commit 29e018c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/graphics/render/ChunksRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const Mesh* ChunksRenderer::getOrRender(
if (found == meshes.end()) {
return render(chunk, important);
}
if (chunk->flags.modified) {
if (chunk->flags.modified && chunk->flags.lighted) {
render(chunk, important);
}
return found->second.mesh.get();
Expand All @@ -149,9 +149,17 @@ const Mesh* ChunksRenderer::retrieveChunk(
size_t index, const Camera& camera, Shader& shader, bool culling
) {
auto chunk = chunks.getChunks()[index];
if (chunk == nullptr || !chunk->flags.lighted) {
if (chunk == nullptr) {
return nullptr;
}
if (!chunk->flags.lighted) {
const auto& found = meshes.find({chunk->x, chunk->z});
if (found == meshes.end()) {
return nullptr;
} else {
return found->second.mesh.get();
}
}
float distance = glm::distance(
camera.position,
glm::vec3(
Expand Down

0 comments on commit 29e018c

Please sign in to comment.