From 31a11a6df4922b590a50a5ff3d3c00d42a45599d Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Mon, 23 Jul 2018 19:12:51 +0100 Subject: Optimise chunk set (#4260) Closes #1244 Initially I was just going to add the cChunkData to cSetChunkData but profiling revealed that the copying wasn't even the biggest slowdown. Much more time was being spent in cChunk::CreateBlockEntities and cChunk::WakeUpSimulators than was in memcpy so I've made those significantly faster as well. Optimisations performed: * cSetChunkData now stores blocks in a cChunkData object * cChunkData objects can now perform moves even if they are using different pools * cChunk::CreateBlockEntities now iterates in the correct order and only over present chunk sections * Similarly for cChunk::WakeUpSimulators * cSetChunkData::CalculateHeightMap now shortcuts to the highest present chunk section before checking blocks directly --- src/SetChunkData.h | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/SetChunkData.h') diff --git a/src/SetChunkData.h b/src/SetChunkData.h index c608a8f61..3e1dde35a 100644 --- a/src/SetChunkData.h +++ b/src/SetChunkData.h @@ -3,12 +3,10 @@ // Declares the cSetChunkData class used for sending loaded / generated chunk data into cWorld - - - - #pragma once +#include "ChunkData.h" + @@ -51,17 +49,8 @@ public: int GetChunkX(void) const { return m_ChunkX; } int GetChunkZ(void) const { return m_ChunkZ; } - /** Returns the internal storage of the block types, read-only. */ - const cChunkDef::BlockTypes & GetBlockTypes(void) const { return m_BlockTypes; } - - /** Returns the internal storage of the block types, read-only. */ - const cChunkDef::BlockNibbles & GetBlockMetas(void) const { return m_BlockMetas; } - - /** Returns the internal storage of the block light, read-only. */ - const cChunkDef::BlockNibbles & GetBlockLight(void) const { return m_BlockLight; } - - /** Returns the internal storage of the block types, read-only. */ - const cChunkDef::BlockNibbles & GetSkyLight(void) const { return m_SkyLight; } + /** Returns the internal storage of block types, metas and lighting. */ + cChunkData & GetChunkData(void) { return m_ChunkData; } /** Returns the internal storage for heightmap, read-only. */ const cChunkDef::HeightMap & GetHeightMap(void) const { return m_HeightMap; } @@ -101,10 +90,8 @@ protected: int m_ChunkX; int m_ChunkZ; - cChunkDef::BlockTypes m_BlockTypes; - cChunkDef::BlockNibbles m_BlockMetas; - cChunkDef::BlockNibbles m_BlockLight; - cChunkDef::BlockNibbles m_SkyLight; + cListAllocationPool m_Pool; + cChunkData m_ChunkData; cChunkDef::HeightMap m_HeightMap; cChunkDef::BiomeMap m_Biomes; cEntityList m_Entities; -- cgit v1.2.3