Skip to content

Commit

Permalink
Tools/mmaps_generator: Mak percentage progress slightly more accurate
Browse files Browse the repository at this point in the history
TrinityCore#18832

(cherry picked from commit 29937aa)

# Conflicts:
#	src/tools/mmaps_generator/MapBuilder.cpp
  • Loading branch information
Shauren authored and Vincent-Michael committed Apr 22, 2017
1 parent a316ba5 commit 457f58b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
20 changes: 8 additions & 12 deletions src/tools/mmaps_generator/MapBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ namespace MMAP
m_skipBattlegrounds (skipBattlegrounds),
m_maxWalkableAngle (maxWalkableAngle),
m_bigBaseUnit (bigBaseUnit),
m_totalTiles (0u),
m_totalTilesProcessed(0u),
m_rcContext (NULL),
_cancelationToken (false)
{
m_terrainBuilder = new TerrainBuilder(skipLiquid);

m_rcContext = new rcContext(false);

// percentageDone - Initializing
m_totalTiles = 0;
m_totalTilesBuilt = 0;

discoverTiles();
}

Expand Down Expand Up @@ -157,8 +155,7 @@ namespace MMAP
}
printf("found %u.\n\n", count);

// percentageDone - total tiles to process
m_totalTiles = count;
m_totalTiles.store(count, std::memory_order_relaxed);
}

/**************************************************************************/
Expand Down Expand Up @@ -393,7 +390,8 @@ namespace MMAP
// add all tiles within bounds to tile list.
for (uint32 i = minX; i <= maxX; ++i)
for (uint32 j = minY; j <= maxY; ++j)
tiles->insert(StaticMapTree::packTileID(i, j));
if (tiles->insert(StaticMapTree::packTileID(i, j)).second)
++m_totalTiles;
}

if (!tiles->empty())
Expand All @@ -404,6 +402,7 @@ namespace MMAP
if (!navMesh)
{
printf("[Map %04i] Failed creating navmesh!\n", mapID);
m_totalTilesProcessed += tiles->size();
return;
}

Expand All @@ -416,6 +415,7 @@ namespace MMAP
// unpack tile coords
StaticMapTree::unpackTileID((*it), tileX, tileY);

++m_totalTilesProcessed;
if (shouldSkipTile(mapID, tileX, tileY))
continue;

Expand All @@ -431,8 +431,7 @@ namespace MMAP
/**************************************************************************/
void MapBuilder::buildTile(uint32 mapID, uint32 tileX, uint32 tileY, dtNavMesh* navMesh)
{
// percentageDone - added, now it will show addional reference percentage done of the overall process
printf("%u%% [Map %04i] Building tile [%02u,%02u]\n", percentageDone(m_totalTiles, m_totalTilesBuilt), mapID, tileX, tileY);
printf("%u%% [Map %04i] Building tile [%02u,%02u]\n", percentageDone(m_totalTiles, m_totalTilesProcessed), mapID, tileX, tileY);

MeshData meshData;

Expand Down Expand Up @@ -466,9 +465,6 @@ namespace MMAP

// build navmesh tile
buildMoveMapTile(mapID, tileX, tileY, meshData, bmin, bmax, navMesh);

// percentageDone - increment tiles built
m_totalTilesBuilt++;
}

/**************************************************************************/
Expand Down
8 changes: 4 additions & 4 deletions src/tools/mmaps_generator/MapBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace MMAP
bool shouldSkipMap(uint32 mapID);
bool isTransportMap(uint32 mapID);
bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY);
// percentageDone - method to calculate percentage

uint32 percentageDone(uint32 totalTiles, uint32 totalTilesDone);

TerrainBuilder* m_terrainBuilder;
Expand All @@ -140,9 +140,9 @@ namespace MMAP

float m_maxWalkableAngle;
bool m_bigBaseUnit;
// percentageDone - variables to calculate percentage
uint32 m_totalTiles;
std::atomic<uint32> m_totalTilesBuilt;

std::atomic<uint32> m_totalTiles;
std::atomic<uint32> m_totalTilesProcessed;

// build performance - not really used for now
rcContext* m_rcContext;
Expand Down

0 comments on commit 457f58b

Please sign in to comment.