From 6d650d5f3c59663c94da8b269d9e5cc3979c3da4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 25 Jul 2020 20:59:12 +0100 Subject: Reduce unnecessary wakeups - cSimulator no longer wakes up positions already woken by cChunk::SetBlock --- src/Chunk.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index d354448ce..fb37ce3b3 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1374,19 +1374,34 @@ void cChunk::QueueTickBlock(Vector3i a_RelPos) void cChunk::QueueTickBlockNeighbors(Vector3i a_RelPos) { - static const Vector3i neighborOfs[] = + // Contains our direct adjacents + // and one block above and below the laterals (for redstone components) + static const Vector3i Offsets[] = { + { 1, 1, 0}, { 1, 0, 0}, + { 1, -1, 0}, + + {-1, 1, 0}, {-1, 0, 0}, - { 0, 1, 0}, - { 0, -1, 0}, + {-1, -1, 0}, + + { 0, 1, 1}, { 0, 0, 1}, + { 0, -1, 1}, + + { 0, 1, -1}, { 0, 0, -1}, - } ; - for (const auto & ofs: neighborOfs) + { 0, -1, -1}, + + { 0, 1, 0}, + { 0, -1, 0}, + }; + + for (const auto & Offset : Offsets) { - UnboundedQueueTickBlock(a_RelPos + ofs); - } // for i - Coords[] + UnboundedQueueTickBlock(a_RelPos + Offset); + } } -- cgit v1.2.3