1
0

change to linear calculation

This commit is contained in:
DayBr3ak 2014-09-03 18:48:47 +02:00
parent 5a608dc279
commit d2bacc34f6
2 changed files with 7 additions and 9 deletions

View File

@ -212,11 +212,10 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile)
// cBioGenMulticache: // cBioGenMulticache:
cBioGenMulticache::cBioGenMulticache(cBiomeGen * a_BioGenToCache, size_t a_CacheSize, size_t a_CachesLength) : cBioGenMulticache::cBioGenMulticache(cBiomeGen * a_BioGenToCache, size_t a_CacheSize, size_t a_CachesLength) :
m_CachesLength(a_CachesLength), m_CachesLength(a_CachesLength)
m_InternalCacheLength(a_CachesLength * a_CacheSize)
{ {
m_Caches.reserve(m_InternalCacheLength); m_Caches.reserve(a_CachesLength);
for (size_t i = 0; i < m_InternalCacheLength; i++) for (size_t i = 0; i < a_CachesLength; i++)
{ {
m_Caches.push_back(new cBioGenCache(a_BioGenToCache, a_CacheSize)); m_Caches.push_back(new cBioGenCache(a_BioGenToCache, a_CacheSize));
} }
@ -240,8 +239,8 @@ cBioGenMulticache::~cBioGenMulticache()
void cBioGenMulticache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) void cBioGenMulticache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{ {
size_t cacheIdx = ((size_t)a_ChunkX % m_CachesLength) * m_CachesLength const size_t coefficient = 3;
+ ((size_t)a_ChunkZ % m_CachesLength); const size_t cacheIdx = ((size_t)a_ChunkX + coefficient * (size_t)a_ChunkZ) % m_CachesLength;
m_Caches[cacheIdx]->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap); m_Caches[cacheIdx]->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
} }

View File

@ -96,7 +96,6 @@ public:
protected: protected:
size_t m_CachesLength; size_t m_CachesLength;
size_t m_InternalCacheLength; // used internally only
std::vector<cBiomeGen*> m_Caches; std::vector<cBiomeGen*> m_Caches;
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;