summaryrefslogtreecommitdiffstats
path: root/src/LightingThread.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-02-21 11:30:48 +0100
committerGitHub <noreply@github.com>2018-02-21 11:30:48 +0100
commit999faa9d90453435ab1c61935a448fef01ff29e7 (patch)
tree2193ede91860539af4212d212b399ee2cefad7ee /src/LightingThread.cpp
parentFix cUrlClient leak (#4125) (diff)
downloadcuberite-999faa9d90453435ab1c61935a448fef01ff29e7.tar
cuberite-999faa9d90453435ab1c61935a448fef01ff29e7.tar.gz
cuberite-999faa9d90453435ab1c61935a448fef01ff29e7.tar.bz2
cuberite-999faa9d90453435ab1c61935a448fef01ff29e7.tar.lz
cuberite-999faa9d90453435ab1c61935a448fef01ff29e7.tar.xz
cuberite-999faa9d90453435ab1c61935a448fef01ff29e7.tar.zst
cuberite-999faa9d90453435ab1c61935a448fef01ff29e7.zip
Diffstat (limited to 'src/LightingThread.cpp')
-rw-r--r--src/LightingThread.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp
index 39b22f748..ccefdfef2 100644
--- a/src/LightingThread.cpp
+++ b/src/LightingThread.cpp
@@ -20,21 +20,31 @@ class cReader :
virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
{
BLOCKTYPE * OutputRows = m_BlockTypes;
- int InputIdx = 0;
int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3;
- int MaxHeight = std::min(+cChunkDef::Height, m_MaxHeight + 16); // Need 16 blocks above the highest
- for (int y = 0; y < MaxHeight; y++)
+ for (size_t i = 0; i != cChunkData::NumSections; ++i)
{
- for (int z = 0; z < cChunkDef::Width; z++)
+ auto * Section = a_ChunkBuffer.GetSection(i);
+ if (Section == nullptr)
+ {
+ // Skip to the next section
+ OutputIdx += 9 * cChunkData::SectionHeight * cChunkDef::Width;
+ continue;
+ }
+
+ for (size_t OffsetY = 0; OffsetY != cChunkData::SectionHeight; ++OffsetY)
{
- a_ChunkBuffer.CopyBlockTypes(OutputRows + OutputIdx * 16, static_cast<size_t>(InputIdx * 16), 16);
- InputIdx++;
- OutputIdx += 3;
- } // for z
- // Skip into the next y-level in the 3x3 chunk blob; each level has cChunkDef::Width * 9 rows
- // We've already walked cChunkDef::Width * 3 in the "for z" cycle, that makes cChunkDef::Width * 6 rows left to skip
- OutputIdx += cChunkDef::Width * 6;
- } // for y
+ for (size_t Z = 0; Z != cChunkDef::Width; ++Z)
+ {
+ auto InPtr = Section->m_BlockTypes + Z * cChunkDef::Width + OffsetY * cChunkDef::Width * cChunkDef::Width;
+ std::copy_n(InPtr, cChunkDef::Width, OutputRows + OutputIdx * cChunkDef::Width);
+
+ OutputIdx += 3;
+ }
+ // Skip into the next y-level in the 3x3 chunk blob; each level has cChunkDef::Width * 9 rows
+ // We've already walked cChunkDef::Width * 3 in the "for z" cycle, that makes cChunkDef::Width * 6 rows left to skip
+ OutputIdx += cChunkDef::Width * 6;
+ }
+ }
} // BlockTypes()
@@ -78,6 +88,7 @@ public:
m_BlockTypes(a_BlockTypes),
m_HeightMap(a_HeightMap)
{
+ std::fill_n(m_BlockTypes, cChunkDef::NumBlocks * 9, E_BLOCK_AIR);
}
} ;