From 945631ba06fcba24c84017f36544667299c591fb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 23 Mar 2014 14:34:19 +0000 Subject: Sort of implementation of chunk sparsing Issues: * Chunks are flipped * Slow/inefficient/badly coded * Only blocktypes are 'compressed' --- src/Chunk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index b3fa563cc..1b83bc540 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -421,7 +421,7 @@ private: cChunkMap * m_ChunkMap; // TODO: Make these pointers and don't allocate what isn't needed - BLOCKTYPE m_BlockTypes [cChunkDef::NumBlocks]; + std::vector> m_BlockTypes; NIBBLETYPE m_BlockMeta [cChunkDef::NumBlocks / 2]; NIBBLETYPE m_BlockLight [cChunkDef::NumBlocks / 2]; NIBBLETYPE m_BlockSkyLight[cChunkDef::NumBlocks / 2]; -- cgit v1.2.3 From 15a0ceec2687c04191c41f7b103c26aeb98705ca Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Apr 2014 13:01:05 +0100 Subject: Speed and memory improvements * Changed array to be continuous, so no more layer splitting --- src/Chunk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index 1b83bc540..ef6a11006 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -421,7 +421,7 @@ private: cChunkMap * m_ChunkMap; // TODO: Make these pointers and don't allocate what isn't needed - std::vector> m_BlockTypes; + std::vector m_BlockTypes; NIBBLETYPE m_BlockMeta [cChunkDef::NumBlocks / 2]; NIBBLETYPE m_BlockLight [cChunkDef::NumBlocks / 2]; NIBBLETYPE m_BlockSkyLight[cChunkDef::NumBlocks / 2]; -- cgit v1.2.3 From 3201d1bf169ca99e4cdbfad7601f6aed89b3c76c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Apr 2014 23:16:52 +0100 Subject: Nibbletypes are compressed + Added nibble compression * Fixed an off by one --- src/Chunk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index ef6a11006..d8e4cf6e4 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -422,7 +422,7 @@ private: // TODO: Make these pointers and don't allocate what isn't needed std::vector m_BlockTypes; - NIBBLETYPE m_BlockMeta [cChunkDef::NumBlocks / 2]; + std::vector m_BlockMeta; NIBBLETYPE m_BlockLight [cChunkDef::NumBlocks / 2]; NIBBLETYPE m_BlockSkyLight[cChunkDef::NumBlocks / 2]; -- cgit v1.2.3 From a42d1f851748c0cca542d1b0038318d0cbff9fd3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 6 Apr 2014 23:30:21 +0100 Subject: Blocklight and skylight now compressed --- src/Chunk.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index d8e4cf6e4..6e2933ff8 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -326,9 +326,9 @@ public: inline void SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); } inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockLight, a_RelX, a_RelY, a_RelZ); } - inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_RelX, a_RelY, a_RelZ); } + inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_RelX, a_RelY, a_RelZ, true); } inline NIBBLETYPE GetBlockLight(int a_Idx) const {return cChunkDef::GetNibble(m_BlockLight, a_Idx); } - inline NIBBLETYPE GetSkyLight (int a_Idx) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_Idx); } + inline NIBBLETYPE GetSkyLight (int a_Idx) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_Idx, true); } /** Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case); returns true on success */ bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; @@ -423,8 +423,8 @@ private: // TODO: Make these pointers and don't allocate what isn't needed std::vector m_BlockTypes; std::vector m_BlockMeta; - NIBBLETYPE m_BlockLight [cChunkDef::NumBlocks / 2]; - NIBBLETYPE m_BlockSkyLight[cChunkDef::NumBlocks / 2]; + std::vector m_BlockLight; + std::vector m_BlockSkyLight; cChunkDef::HeightMap m_HeightMap; cChunkDef::BiomeMap m_BiomeMap; -- cgit v1.2.3 From f13cf1a0217437113ad5372ef971c3903d55a9c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Apr 2014 20:57:14 +0100 Subject: Maybe speed improvements? * Use a single index to determine from when to begin copying data * Use heightmap to determine first nonair block --- src/Chunk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index 6e2933ff8..9100eec58 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -267,7 +267,7 @@ public: void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords void CalculateLighting(); // Recalculate right now - void CalculateHeightmap(); + void CalculateHeightmap(const BLOCKTYPE * a_BlockTypes); // Broadcast various packets to all clients of this chunk: // (Please keep these alpha-sorted) -- cgit v1.2.3 From 05f52192c9389f0c28cc6d772f3625c9588273a1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 25 Apr 2014 21:22:43 +0100 Subject: Implemented comments --- src/Chunk.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index 9100eec58..a9c9be861 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -421,10 +421,10 @@ private: cChunkMap * m_ChunkMap; // TODO: Make these pointers and don't allocate what isn't needed - std::vector m_BlockTypes; - std::vector m_BlockMeta; - std::vector m_BlockLight; - std::vector m_BlockSkyLight; + COMPRESSED_BLOCKTYPE m_BlockTypes; + COMPRESSED_NIBBLETYPE m_BlockMeta; + COMPRESSED_NIBBLETYPE m_BlockLight; + COMPRESSED_NIBBLETYPE m_BlockSkyLight; cChunkDef::HeightMap m_HeightMap; cChunkDef::BiomeMap m_BiomeMap; -- cgit v1.2.3