From c53b7e5d38c24bce7ba55abf3060ffd012783086 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 27 Oct 2014 23:58:09 +0100 Subject: QtBiomeVisualiser: Switched caching to entire regions. This speeds up the rendering preparation for small zooms. --- Tools/QtBiomeVisualiser/ChunkSource.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Tools/QtBiomeVisualiser/ChunkSource.cpp') diff --git a/Tools/QtBiomeVisualiser/ChunkSource.cpp b/Tools/QtBiomeVisualiser/ChunkSource.cpp index c5cde1c3b..c6d50b2e0 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.cpp +++ b/Tools/QtBiomeVisualiser/ChunkSource.cpp @@ -24,14 +24,14 @@ BioGenSource::BioGenSource(cIniFilePtr a_IniFile) : -void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) +void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) { cChunkDef::BiomeMap biomes; { QMutexLocker lock(&m_Mtx); m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, biomes); } - a_DestChunk->setBiomes(biomes); + a_DestChunk.setBiomes(biomes); } @@ -160,7 +160,7 @@ AnvilSource::AnvilSource(QString a_WorldRegionFolder) : -void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) +void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) { // Load the compressed data: AString compressedChunkData = getCompressedChunkData(a_ChunkX, a_ChunkZ); @@ -200,7 +200,7 @@ void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChun { biomeMap[i] = (EMCSBiome)GetBEInt(beBiomes + 4 * i); } - a_DestChunk->setBiomes(biomeMap); + a_DestChunk.setBiomes(biomeMap); return; } @@ -216,7 +216,7 @@ void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChun { biomeMap[i] = EMCSBiome(vanillaBiomes[i]); } - a_DestChunk->setBiomes(biomeMap); + a_DestChunk.setBiomes(biomeMap); } -- cgit v1.2.3 From 53ff5c527c154348608f9ab9559bf67064c8ed2a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 28 Oct 2014 11:23:54 +0100 Subject: QtBiomeVisualiser: Attempt at fixing Linux compilation. --- Tools/QtBiomeVisualiser/ChunkSource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/ChunkSource.cpp') diff --git a/Tools/QtBiomeVisualiser/ChunkSource.cpp b/Tools/QtBiomeVisualiser/ChunkSource.cpp index c6d50b2e0..d9660b886 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.cpp +++ b/Tools/QtBiomeVisualiser/ChunkSource.cpp @@ -260,7 +260,7 @@ AnvilSource::AnvilFilePtr AnvilSource::getAnvilFile(int a_ChunkX, int a_ChunkZ) // Search the cache for the file: QMutexLocker lock(&m_Mtx); - for (auto itr = m_Files.cbegin(), end = m_Files.cend(); itr != end; ++itr) + for (auto itr = m_Files.begin(), end = m_Files.end(); itr != end; ++itr) { if (((*itr)->m_RegionX == RegionX) && ((*itr)->m_RegionZ == RegionZ)) { -- cgit v1.2.3 From 4e0cef0ff6080b67e4740bd33ccf4a491a82fb52 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 29 Oct 2014 23:04:59 +0100 Subject: QtBiomeVisualiser: Generator uses all machine threads. The previous limit of 1 thread was lifted, now the generator source runs on all CPU threads available. --- Tools/QtBiomeVisualiser/ChunkSource.cpp | 57 +++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 7 deletions(-) (limited to 'Tools/QtBiomeVisualiser/ChunkSource.cpp') diff --git a/Tools/QtBiomeVisualiser/ChunkSource.cpp b/Tools/QtBiomeVisualiser/ChunkSource.cpp index d9660b886..ea3346f04 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.cpp +++ b/Tools/QtBiomeVisualiser/ChunkSource.cpp @@ -27,10 +27,10 @@ BioGenSource::BioGenSource(cIniFilePtr a_IniFile) : void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) { cChunkDef::BiomeMap biomes; - { - QMutexLocker lock(&m_Mtx); - m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, biomes); - } + int tag; + cBiomeGenPtr biomeGen = getBiomeGen(tag); + biomeGen->GenBiomes(a_ChunkX, a_ChunkZ, biomes); + releaseBiomeGen(std::move(biomeGen), tag); a_DestChunk.setBiomes(biomes); } @@ -40,10 +40,53 @@ void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChun void BioGenSource::reload() { - int seed = m_IniFile->GetValueSetI("Seed", "Seed", 0); - bool unused = false; QMutexLocker lock(&m_Mtx); - m_BiomeGen = cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused); + m_CurrentTag += 1; + m_BiomeGens.clear(); +} + + + + + +cBiomeGenPtr BioGenSource::getBiomeGen(int & a_Tag) +{ + QMutexLocker lock(&m_Mtx); + a_Tag = m_CurrentTag; + if (m_BiomeGens.empty()) + { + // Create a new biogen: + lock.unlock(); + int seed = m_IniFile->GetValueSetI("Seed", "Seed", 0); + bool unused; + cBiomeGenPtr res = cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused); + return res; + } + else + { + // Return an existing biogen: + cBiomeGenPtr res = m_BiomeGens.back(); + m_BiomeGens.pop_back(); + return res; + } +} + + + + + +void BioGenSource::releaseBiomeGen(cBiomeGenPtr && a_BiomeGen, int a_Tag) +{ + QMutexLocker lock(&m_Mtx); + + // If the tag differs, the source has been reloaded and this biogen is old, dispose: + if (a_Tag != m_CurrentTag) + { + return; + } + + // The tag is the same, put the biogen back to list: + m_BiomeGens.push_back(std::move(a_BiomeGen)); } -- cgit v1.2.3