Tools/MMapsGenerator: Add some more input parameters to improve mmaps load performances (#25520)

* Some research about mmaps load performances

* Tools/MMapsGenerator: Add some more input parameters

Add some more input parameters which affect the resulting mmaps:
- --smallOutputSize: sets both walkableSlopeAngle and walkableSlopeAngleNotSteep to 55°, reducing by a lot the .mmtile size and the number of polys. A rcFilterLedgeSpans() call is included too to filter out some polys. Default to false.
- --maxAngle: Restore this parameter removed some commits ago. Specifies the max walkable angle of a Creature when in combat. Default to 85
- --maxAngleNotSteep: Max walkable angle of a Player and of a Creature out of combat. Must be less or equal than --maxAngle. Default to 55.

A performance profiling comparison highlighted that .mmtile load grows exponential with the number of polys. A small server with GridUnload enabled and without preloading all grids on startup will be more affected than a big server with GridUnload disabled and preloading grids on startup.
# Conflicts:
#	src/tools/mmaps_generator/PathGenerator.cpp
This commit is contained in:
Giacomo Pozzoni authored and Ovahlord committed 2020-10-16 15:50:59 +02:00
1 parent c34533432a
commit 1de869764d
3 files changed
+64 -13

No files matched your search

+17 -6
View File
@@ -31,16 +31,19 @@
namespace MMAP
{
MapBuilder::MapBuilder(bool skipLiquid,
MapBuilder::MapBuilder(Optional<float> maxWalkableAngle, Optional<float> maxWalkableAngleNotSteep, bool skipLiquid,
bool skipContinents, bool skipJunkMaps, bool skipBattlegrounds,
bool debugOutput, bool bigBaseUnit, int mapid, char const* offMeshFilePath) :
bool debugOutput, bool bigBaseUnit, bool smallOutputSize, int mapid, char const* offMeshFilePath) :
m_terrainBuilder (nullptr),
m_debugOutput (debugOutput),
m_offMeshFilePath (offMeshFilePath),
m_skipContinents (skipContinents),
m_skipJunkMaps (skipJunkMaps),
m_skipBattlegrounds (skipBattlegrounds),
m_maxWalkableAngle (maxWalkableAngle),
m_maxWalkableAngleNotSteep (maxWalkableAngleNotSteep),
m_bigBaseUnit (bigBaseUnit),
m_smallOutputSize (smallOutputSize),
m_mapid (mapid),
m_totalTiles (0u),
m_totalTilesProcessed(0u),
@@ -605,8 +608,9 @@ namespace MMAP
delete[] triFlags;
rcFilterLowHangingWalkableObstacles(m_rcContext, config.walkableClimb, *tile.solid);
// disabled as it ignores walkableSlopeAngle settings
//rcFilterLedgeSpans(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid);
// disabled by default as it ignores walkableSlopeAngle settings
if (m_smallOutputSize)
rcFilterLedgeSpans(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid);
rcFilterWalkableLowHeightSpans(m_rcContext, tileCfg.walkableHeight, *tile.solid);
// add liquid triangles
@@ -840,6 +844,11 @@ namespace MMAP
header.size = uint32(navDataSize);
fwrite(&header, sizeof(MmapTileHeader), 1, file);
/*
dtMeshHeader* navDataHeader = (dtMeshHeader*)navData;
printf("Poly count: %d\n", navDataHeader->polyCount);
*/
// write data
fwrite(navData, sizeof(unsigned char), navDataSize, file);
fclose(file);
@@ -1042,8 +1051,10 @@ namespace MMAP
config.maxVertsPerPoly = DT_VERTS_PER_POLYGON;
config.cs = tileConfig.BASE_UNIT_DIM;
config.ch = tileConfig.BASE_UNIT_DIM;
config.walkableSlopeAngle = 85;
config.walkableSlopeAngleNotSteep = 55;
// Keeping these 2 slope angles the same reduces a lot the number of polys.
// 55 should be the minimum, maybe 70 is ok (keep in mind blink uses mmaps), 85 is too much for players
config.walkableSlopeAngle = m_maxWalkableAngle ? *m_maxWalkableAngle : m_smallOutputSize ? 55 : 85;
config.walkableSlopeAngleNotSteep = m_maxWalkableAngleNotSteep ? *m_maxWalkableAngleNotSteep : 55;
config.tileSize = tileConfig.VERTEX_PER_TILE;
config.walkableRadius = m_bigBaseUnit ? 1 : 2;
config.borderSize = config.walkableRadius + 3;