mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 19:35:42 +00:00
feat(Tools/MMapsGenerator): percentage progress (#10948)
* cherry-pick commit (TrinityCore/TrinityCore@b9f276f) * cherry-pick commit (TrinityCore/TrinityCore@29937aa)
This commit is contained in:
committed by
GitHub
parent
659775548f
commit
7cb9a73ef9
@@ -28,7 +28,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_debugOutput (debugOutput),
|
||||
m_offMeshFilePath (offMeshFilePath),
|
||||
@@ -37,6 +37,9 @@ namespace MMAP
|
||||
m_skipBattlegrounds (skipBattlegrounds),
|
||||
m_maxWalkableAngle (maxWalkableAngle),
|
||||
m_bigBaseUnit (bigBaseUnit),
|
||||
m_mapid (mapid),
|
||||
m_totalTiles (0u),
|
||||
m_totalTilesProcessed(0u),
|
||||
|
||||
_cancelationToken (false)
|
||||
{
|
||||
@@ -44,10 +47,6 @@ namespace MMAP
|
||||
|
||||
m_rcContext = new rcContext(false);
|
||||
|
||||
// percentageDone - Initializing
|
||||
m_totalTiles = 0;
|
||||
m_totalTilesBuilt = 0;
|
||||
|
||||
discoverTiles();
|
||||
}
|
||||
|
||||
@@ -376,19 +375,6 @@ namespace MMAP
|
||||
{
|
||||
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)
|
||||
tiles->insert(StaticMapTree::packTileID(i, j));
|
||||
}
|
||||
|
||||
if (!tiles->empty())
|
||||
{
|
||||
// build navMesh
|
||||
@@ -397,6 +383,7 @@ namespace MMAP
|
||||
if (!navMesh)
|
||||
{
|
||||
printf("[Map %03i] Failed creating navmesh!\n", mapID);
|
||||
m_totalTilesProcessed += tiles->size();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -404,17 +391,15 @@ namespace MMAP
|
||||
printf("[Map %03i] We have %u tiles. \n", mapID, (unsigned int)tiles->size());
|
||||
for (unsigned int tile : *tiles)
|
||||
{
|
||||
// percentageDone - increment tiles built
|
||||
m_totalTilesBuilt++;
|
||||
uint32 tileX, tileY;
|
||||
|
||||
// unpack tile coords
|
||||
StaticMapTree::unpackTileID(tile, tileX, tileY);
|
||||
|
||||
if (shouldSkipTile(mapID, tileX, tileY))
|
||||
continue;
|
||||
if (!shouldSkipTile(mapID, tileX, tileY))
|
||||
buildTile(mapID, tileX, tileY, navMesh);
|
||||
|
||||
buildTile(mapID, tileX, tileY, navMesh);
|
||||
++m_totalTilesProcessed;
|
||||
}
|
||||
|
||||
dtFreeNavMesh(navMesh);
|
||||
@@ -426,8 +411,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 %03i] Building tile [%02u,%02u]\n", percentageDone(m_totalTiles, m_totalTilesBuilt), mapID, tileX, tileY);
|
||||
printf("%u%% [Map %03i] Building tile [%02u,%02u]\n", percentageDone(m_totalTiles, m_totalTilesProcessed), mapID, tileX, tileY);
|
||||
|
||||
MeshData meshData;
|
||||
|
||||
@@ -902,6 +886,9 @@ namespace MMAP
|
||||
/**************************************************************************/
|
||||
bool MapBuilder::shouldSkipMap(uint32 mapID)
|
||||
{
|
||||
if (m_mapid >= 0)
|
||||
return static_cast<uint32>(m_mapid) != mapID;
|
||||
|
||||
if (m_skipContinents)
|
||||
switch (mapID)
|
||||
{
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace MMAP
|
||||
bool skipBattlegrounds = false,
|
||||
bool debugOutput = false,
|
||||
bool bigBaseUnit = false,
|
||||
int mapid = -1,
|
||||
const char* offMeshFilePath = nullptr);
|
||||
|
||||
~MapBuilder();
|
||||
@@ -124,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{nullptr};
|
||||
@@ -139,9 +140,10 @@ namespace MMAP
|
||||
|
||||
float m_maxWalkableAngle;
|
||||
bool m_bigBaseUnit;
|
||||
// percentageDone - variables to calculate percentage
|
||||
int32 m_mapid;
|
||||
|
||||
std::atomic<uint32> m_totalTiles;
|
||||
std::atomic<uint32> m_totalTilesBuilt;
|
||||
std::atomic<uint32> m_totalTilesProcessed;
|
||||
|
||||
// build performance - not really used for now
|
||||
rcContext* m_rcContext{nullptr};
|
||||
|
||||
@@ -278,7 +278,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)
|
||||
|
||||
Reference in New Issue
Block a user