1
0

Implemented Chunk Sparsing with segments

This commit is contained in:
Tycho
2014-04-26 10:50:23 -07:00
parent 01546020fc
commit e40f9d6e5b
17 changed files with 612 additions and 403 deletions

View File

@@ -18,20 +18,17 @@
class cReader :
public cChunkDataCallback
{
virtual void BlockTypes(const BLOCKTYPE * a_Type) override
virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override
{
// ROW is a block of 16 Blocks, one whole row is copied at a time (hopefully the compiler will optimize that)
// C++ doesn't permit copying arrays, but arrays as a part of a struct is ok :)
typedef struct {BLOCKTYPE m_Row[16]; } ROW;
ROW * InputRows = (ROW *)a_Type;
ROW * OutputRows = (ROW *)m_BlockTypes;
BLOCKTYPE * OutputRows = m_BlockTypes;
int InputIdx = 0;
int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3;
for (int y = 0; y < cChunkDef::Height; y++)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
OutputRows[OutputIdx] = InputRows[InputIdx++];
a_ChunkBuffer.CopyBlocks(OutputRows + OutputIdx * 16, 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