Tools/MMapsGenerator: Get all tiles in beginning and calulate proper total tile count (#21139)

This commit is contained in:
Rochet2
2017-12-30 18:47:30 +02:00
committed by Shauren
parent a6594c3831
commit bbd7e3e326
3 changed files with 31 additions and 25 deletions

View File

@@ -57,7 +57,7 @@ namespace MMAP
{
MapBuilder::MapBuilder(float maxWalkableAngle, bool skipLiquid,
bool skipContinents, bool skipJunkMaps, bool skipBattlegrounds,
bool debugOutput, bool bigBaseUnit, const char* offMeshFilePath) :
bool debugOutput, bool bigBaseUnit, int mapid, const char* offMeshFilePath) :
m_terrainBuilder (NULL),
m_debugOutput (debugOutput),
m_offMeshFilePath (offMeshFilePath),
@@ -66,6 +66,7 @@ namespace MMAP
m_skipBattlegrounds (skipBattlegrounds),
m_maxWalkableAngle (maxWalkableAngle),
m_bigBaseUnit (bigBaseUnit),
m_mapid (mapid),
m_totalTiles (0u),
m_totalTilesProcessed(0u),
m_rcContext (NULL),
@@ -152,10 +153,29 @@ namespace MMAP
if (tiles->insert(tileID).second)
count++;
}
// make sure we process maps which don't have tiles
if (tiles->empty())
{
// convert coord bounds to grid bounds
uint32 minX, minY, maxX, maxY;
getGridBounds(mapID, minX, minY, maxX, maxY);
// add all tiles within bounds to tile list.
for (uint32 i = minX; i <= maxX; ++i)
for (uint32 j = minY; j <= maxY; ++j)
if (tiles->insert(StaticMapTree::packTileID(i, j)).second)
count++;
}
}
printf("found %u.\n\n", count);
m_totalTiles.store(count, std::memory_order_relaxed);
// Calculate tiles to process in total
for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
{
if (!shouldSkipMap(it->m_mapId))
m_totalTiles += it->m_tiles->size();
}
}
/**************************************************************************/
@@ -374,26 +394,8 @@ namespace MMAP
/**************************************************************************/
void MapBuilder::buildMap(uint32 mapID)
{
#ifndef __APPLE__
//printf("[Thread %u] Building map %04u:\n", uint32(ACE_Thread::self()), mapID);
#endif
std::set<uint32>* tiles = getTileList(mapID);
// make sure we process maps which don't have tiles
if (!tiles->size())
{
// convert coord bounds to grid bounds
uint32 minX, minY, maxX, maxY;
getGridBounds(mapID, minX, minY, maxX, maxY);
// add all tiles within bounds to tile list.
for (uint32 i = minX; i <= maxX; ++i)
for (uint32 j = minY; j <= maxY; ++j)
if (tiles->insert(StaticMapTree::packTileID(i, j)).second)
++m_totalTiles;
}
if (!tiles->empty())
{
// build navMesh
@@ -415,11 +417,9 @@ namespace MMAP
// unpack tile coords
StaticMapTree::unpackTileID((*it), tileX, tileY);
if (!shouldSkipTile(mapID, tileX, tileY))
buildTile(mapID, tileX, tileY, navMesh);
++m_totalTilesProcessed;
if (shouldSkipTile(mapID, tileX, tileY))
continue;
buildTile(mapID, tileX, tileY, navMesh);
}
dtFreeNavMesh(navMesh);
@@ -907,6 +907,9 @@ namespace MMAP
/**************************************************************************/
bool MapBuilder::shouldSkipMap(uint32 mapID)
{
if (m_mapid >= 0)
return static_cast<uint32>(m_mapid) != mapID;
if (m_skipContinents)
switch (mapID)
{

View File

@@ -83,6 +83,7 @@ namespace MMAP
bool skipBattlegrounds = false,
bool debugOutput = false,
bool bigBaseUnit = false,
int mapid = -1,
const char* offMeshFilePath = NULL);
~MapBuilder();
@@ -141,6 +142,8 @@ namespace MMAP
float m_maxWalkableAngle;
bool m_bigBaseUnit;
int32 m_mapid;
std::atomic<uint32> m_totalTiles;
std::atomic<uint32> m_totalTilesProcessed;

View File

@@ -281,7 +281,7 @@ int main(int argc, char** argv)
return silent ? -3 : finish("Press ENTER to close...", -3);
MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps,
skipBattlegrounds, debugOutput, bigBaseUnit, offMeshInputPath);
skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath);
uint32 start = getMSTime();
if (file)