From 08e3d16a58434b1871330d862f21d5897c6af744 Mon Sep 17 00:00:00 2001 From: x2048 Date: Sun, 14 Aug 2022 20:29:20 +0200 Subject: [PATCH] Limit force shadow update to urgent blocks (#12692) --- src/client/client.cpp | 3 ++- src/client/mesh_generator_thread.cpp | 3 +++ src/client/mesh_generator_thread.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index 31bbf2463..b7d1cbfe0 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -574,7 +574,8 @@ void Client::step(float dtime) else { // Replace with the new mesh block->mesh = r.mesh; - force_update_shadows = true; + if (r.urgent) + force_update_shadows = true; } } } else { diff --git a/src/client/mesh_generator_thread.cpp b/src/client/mesh_generator_thread.cpp index c1bd7388e..ec567c8c1 100644 --- a/src/client/mesh_generator_thread.cpp +++ b/src/client/mesh_generator_thread.cpp @@ -113,6 +113,7 @@ bool MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool q->ack_block_to_server = true; q->crack_level = m_client->getCrackLevel(); q->crack_pos = m_client->getCrackPos(); + q->urgent |= urgent; return true; } } @@ -125,6 +126,7 @@ bool MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool q->ack_block_to_server = ack_block_to_server; q->crack_level = m_client->getCrackLevel(); q->crack_pos = m_client->getCrackPos(); + q->urgent = urgent; m_queue.push_back(q); // This queue entry is a new reference to the cached blocks @@ -310,6 +312,7 @@ void MeshUpdateThread::doUpdate() r.p = q->p; r.mesh = mesh_new; r.ack_block_to_server = q->ack_block_to_server; + r.urgent = q->urgent; m_queue_out.push_back(r); diff --git a/src/client/mesh_generator_thread.h b/src/client/mesh_generator_thread.h index 552b2a9f0..09400196d 100644 --- a/src/client/mesh_generator_thread.h +++ b/src/client/mesh_generator_thread.h @@ -45,6 +45,7 @@ struct QueuedMeshUpdate int crack_level = -1; v3s16 crack_pos; MeshMakeData *data = nullptr; // This is generated in MeshUpdateQueue::pop() + bool urgent = false; QueuedMeshUpdate() = default; ~QueuedMeshUpdate(); @@ -105,6 +106,7 @@ struct MeshUpdateResult v3s16 p = v3s16(-1338, -1338, -1338); MapBlockMesh *mesh = nullptr; bool ack_block_to_server = false; + bool urgent = false; MeshUpdateResult() = default; };