Core/Mmaps: Make the mmaps_generator multithreaded, you can specify the max number of threads that are spawned at the same time (default 3) by using "--threads x" in the command line, where x is the number of threads you want.
Core/Mmaps: Removed now useless sh script
This commit is contained in:
1 parent
9698d295b2
commit
f8cc38d65a
11 files changed
+78
-356
No files matched your search
@@ -158,13 +158,31 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void MapBuilder::buildAllMaps()
|
||||
void MapBuilder::buildAllMaps(int threads)
|
||||
{
|
||||
int running = 0;
|
||||
for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
|
||||
{
|
||||
uint32 mapID = (*it).first;
|
||||
if (!shouldSkipMap(mapID))
|
||||
buildMap(mapID);
|
||||
{
|
||||
if (threads > 1)
|
||||
{
|
||||
BuilderThread* thread = new BuilderThread(this, mapID);
|
||||
thread->activate();
|
||||
++running;
|
||||
// Do not allow more than {threads} threads running at the same time
|
||||
if (running == threads)
|
||||
{
|
||||
// Wait for previous threads to finish
|
||||
ACE_Thread_Manager::instance()->wait();
|
||||
// Reset the number of running threads
|
||||
running = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
buildMap(mapID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +324,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
// now start building mmtiles for each tile
|
||||
printf("We have %u tiles. \n", (unsigned int)tiles->size());
|
||||
printf("[Map %i] We have %u tiles. \n", mapID, (unsigned int)tiles->size());
|
||||
for (set<uint32>::iterator it = tiles->begin(); it != tiles->end(); ++it)
|
||||
{
|
||||
uint32 tileX, tileY;
|
||||
@@ -415,10 +433,10 @@ namespace MMAP
|
||||
navMeshParams.maxPolys = maxPolysPerTile;
|
||||
|
||||
navMesh = dtAllocNavMesh();
|
||||
printf("Creating navMesh... \r");
|
||||
printf("[Map %i] Creating navMesh...\n", mapID);
|
||||
if (!navMesh->init(&navMeshParams))
|
||||
{
|
||||
printf("Failed creating navmesh! \n");
|
||||
printf("[Map %i] Failed creating navmesh! \n", mapID);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -430,7 +448,7 @@ namespace MMAP
|
||||
{
|
||||
dtFreeNavMesh(navMesh);
|
||||
char message[1024];
|
||||
sprintf(message, "Failed to open %s for writing!\n", fileName);
|
||||
sprintf(message, "[Map %i] Failed to open %s for writing!\n", mapID, fileName);
|
||||
perror(message);
|
||||
return;
|
||||
}
|
||||
@@ -446,9 +464,9 @@ namespace MMAP
|
||||
dtNavMesh* navMesh)
|
||||
{
|
||||
// console output
|
||||
char tileString[10];
|
||||
sprintf(tileString, "[%02i,%02i]: ", tileX, tileY);
|
||||
printf("%s Building movemap tiles... \r", tileString);
|
||||
char tileString[20];
|
||||
sprintf(tileString, "[Map %03i] [%02i,%02i]: ", mapID, tileX, tileY);
|
||||
printf("%s Building movemap tiles...\n", tileString);
|
||||
|
||||
IntermediateValues iv;
|
||||
|
||||
@@ -510,14 +528,14 @@ namespace MMAP
|
||||
rcPolyMesh** pmmerge = new rcPolyMesh*[TILES_PER_MAP * TILES_PER_MAP];
|
||||
if (!pmmerge)
|
||||
{
|
||||
printf("%s alloc pmmerge FIALED! \r", tileString);
|
||||
printf("%s alloc pmmerge FIALED!\n", tileString);
|
||||
return;
|
||||
}
|
||||
|
||||
rcPolyMeshDetail** dmmerge = new rcPolyMeshDetail*[TILES_PER_MAP * TILES_PER_MAP];
|
||||
if (!dmmerge)
|
||||
{
|
||||
printf("%s alloc dmmerge FIALED! \r", tileString);
|
||||
printf("%s alloc dmmerge FIALED!\n", tileString);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -539,7 +557,7 @@ namespace MMAP
|
||||
tile.solid = rcAllocHeightfield();
|
||||
if (!tile.solid || !rcCreateHeightfield(m_rcContext, *tile.solid, tileCfg.width, tileCfg.height, tileCfg.bmin, tileCfg.bmax, tileCfg.cs, tileCfg.ch))
|
||||
{
|
||||
printf("%sFailed building heightfield! \n", tileString);
|
||||
printf("%s Failed building heightfield! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -560,33 +578,33 @@ namespace MMAP
|
||||
tile.chf = rcAllocCompactHeightfield();
|
||||
if (!tile.chf || !rcBuildCompactHeightfield(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid, *tile.chf))
|
||||
{
|
||||
printf("%sFailed compacting heightfield! \n", tileString);
|
||||
printf("%s Failed compacting heightfield! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
// build polymesh intermediates
|
||||
if (!rcErodeWalkableArea(m_rcContext, config.walkableRadius, *tile.chf))
|
||||
{
|
||||
printf("%sFailed eroding area! \n", tileString);
|
||||
printf("%s Failed eroding area! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcBuildDistanceField(m_rcContext, *tile.chf))
|
||||
{
|
||||
printf("%sFailed building distance field! \n", tileString);
|
||||
printf("%s Failed building distance field! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcBuildRegions(m_rcContext, *tile.chf, tileCfg.borderSize, tileCfg.minRegionArea, tileCfg.mergeRegionArea))
|
||||
{
|
||||
printf("%sFailed building regions! \n", tileString);
|
||||
printf("%s Failed building regions! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
tile.cset = rcAllocContourSet();
|
||||
if (!tile.cset || !rcBuildContours(m_rcContext, *tile.chf, tileCfg.maxSimplificationError, tileCfg.maxEdgeLen, *tile.cset))
|
||||
{
|
||||
printf("%sFailed building contours! \n", tileString);
|
||||
printf("%s Failed building contours! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -594,14 +612,14 @@ namespace MMAP
|
||||
tile.pmesh = rcAllocPolyMesh();
|
||||
if (!tile.pmesh || !rcBuildPolyMesh(m_rcContext, *tile.cset, tileCfg.maxVertsPerPoly, *tile.pmesh))
|
||||
{
|
||||
printf("%sFailed building polymesh! \n", tileString);
|
||||
printf("%s Failed building polymesh! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
tile.dmesh = rcAllocPolyMeshDetail();
|
||||
if (!tile.dmesh || !rcBuildPolyMeshDetail(m_rcContext, *tile.pmesh, *tile.chf, tileCfg.detailSampleDist, tileCfg .detailSampleMaxError, *tile.dmesh))
|
||||
{
|
||||
printf("%sFailed building polymesh detail! \n", tileString);
|
||||
printf("%s Failed building polymesh detail! \n", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -627,7 +645,7 @@ namespace MMAP
|
||||
iv.polyMesh = rcAllocPolyMesh();
|
||||
if (!iv.polyMesh)
|
||||
{
|
||||
printf("%s alloc iv.polyMesh FIALED! \r", tileString);
|
||||
printf("%s alloc iv.polyMesh FIALED!\n", tileString);
|
||||
return;
|
||||
}
|
||||
rcMergePolyMeshes(m_rcContext, pmmerge, nmerge, *iv.polyMesh);
|
||||
@@ -635,16 +653,16 @@ namespace MMAP
|
||||
iv.polyMeshDetail = rcAllocPolyMeshDetail();
|
||||
if (!iv.polyMeshDetail)
|
||||
{
|
||||
printf("%s alloc m_dmesh FIALED! \r", tileString);
|
||||
printf("%s alloc m_dmesh FIALED!\n", tileString);
|
||||
return;
|
||||
}
|
||||
rcMergePolyMeshDetails(m_rcContext, dmmerge, nmerge, *iv.polyMeshDetail);
|
||||
|
||||
// free things up
|
||||
delete [] pmmerge;
|
||||
delete [] dmmerge;
|
||||
delete[] pmmerge;
|
||||
delete[] dmmerge;
|
||||
|
||||
delete [] tiles;
|
||||
delete[] tiles;
|
||||
|
||||
// remove padding for extraction
|
||||
for (int i = 0; i < iv.polyMesh->nverts; ++i)
|
||||
@@ -736,7 +754,7 @@ namespace MMAP
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s Building navmesh tile... \r", tileString);
|
||||
printf("%s Building navmesh tile...\n", tileString);
|
||||
if (!dtCreateNavMeshData(¶ms, &navData, &navDataSize))
|
||||
{
|
||||
printf("%s Failed building navmesh tile! \n", tileString);
|
||||
@@ -744,7 +762,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
dtTileRef tileRef = 0;
|
||||
printf("%s Adding tile to navmesh... \r", tileString);
|
||||
printf("%s Adding tile to navmesh...\n", tileString);
|
||||
// DT_TILE_FREE_DATA tells detour to unallocate memory when the tile
|
||||
// is removed via removeTile()
|
||||
dtStatus dtResult = navMesh->addTile(navData, navDataSize, DT_TILE_FREE_DATA, 0, &tileRef);
|
||||
@@ -761,13 +779,13 @@ namespace MMAP
|
||||
if (!file)
|
||||
{
|
||||
char message[1024];
|
||||
sprintf(message, "Failed to open %s for writing!\n", fileName);
|
||||
sprintf(message, "[Map %i] Failed to open %s for writing!\n", mapID, fileName);
|
||||
perror(message);
|
||||
navMesh->removeTile(tileRef, NULL, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s Writing to file... \r", tileString);
|
||||
printf("%s Writing to file...\n", tileString);
|
||||
|
||||
// write header
|
||||
MmapTileHeader header;
|
||||
|
||||
Reference in new issue
Block a user