1
0

Reduce unnecessary wakeups

- cSimulator no longer wakes up positions already woken by cChunk::SetBlock
This commit is contained in:
Tiger Wang 2020-07-25 20:59:12 +01:00
parent e4c09ca87d
commit 6d650d5f3c
2 changed files with 22 additions and 19 deletions

View File

@ -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},
{-1, -1, 0},
{ 0, 1, 1},
{ 0, 0, 1},
{ 0, -1, 1},
{ 0, 1, -1},
{ 0, 0, -1},
{ 0, -1, -1},
{ 0, 1, 0},
{ 0, -1, 0},
{ 0, 0, 1},
{ 0, 0, -1},
} ;
for (const auto & ofs: neighborOfs)
};
for (const auto & Offset : Offsets)
{
UnboundedQueueTickBlock(a_RelPos + ofs);
} // for i - Coords[]
UnboundedQueueTickBlock(a_RelPos + Offset);
}
}

View File

@ -21,18 +21,6 @@
void cSimulator::WakeUp(Vector3i a_Block, cChunk * a_Chunk)
{
AddBlock(a_Block, a_Chunk);
AddBlock(a_Block + Vector3i(-1, 0, 0), a_Chunk->GetNeighborChunk(a_Block.x - 1, a_Block.z));
AddBlock(a_Block + Vector3i( 1, 0, 0), a_Chunk->GetNeighborChunk(a_Block.x + 1, a_Block.z));
AddBlock(a_Block + Vector3i(0, 0, -1), a_Chunk->GetNeighborChunk(a_Block.x, a_Block.z - 1));
AddBlock(a_Block + Vector3i(0, 0, 1), a_Chunk->GetNeighborChunk(a_Block.x, a_Block.z + 1));
if (a_Block.y > 0)
{
AddBlock(a_Block + Vector3i(0, -1, 0), a_Chunk);
}
if (a_Block.y < cChunkDef::Height - 1)
{
AddBlock(a_Block + Vector3i(0, 1, 0), a_Chunk);
}
}