diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 23 | ||||
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.h | 9 | ||||
-rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 45 |
3 files changed, 64 insertions, 13 deletions
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index 1b83daf1c1c..b21461c3481 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -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), @@ -602,8 +605,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 @@ -836,6 +840,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); @@ -987,8 +996,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; diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h index 312d3c07786..8b6a18ef769 100644 --- a/src/tools/mmaps_generator/MapBuilder.h +++ b/src/tools/mmaps_generator/MapBuilder.h @@ -30,6 +30,7 @@ #include "Recast.h" #include "DetourNavMesh.h" +#include "Optional.h" #include "ProducerConsumerQueue.h" using namespace VMAP; @@ -96,12 +97,15 @@ namespace MMAP class MapBuilder { public: - MapBuilder(bool skipLiquid = false, + MapBuilder(Optional<float> maxWalkableAngle, + Optional<float> maxWalkableAngleNotSteep, + bool skipLiquid = false, bool skipContinents = false, bool skipJunkMaps = true, bool skipBattlegrounds = false, bool debugOutput = false, bool bigBaseUnit = false, + bool smallOutputSize = false, int mapid = -1, char const* offMeshFilePath = nullptr); @@ -163,7 +167,10 @@ namespace MMAP bool m_skipJunkMaps; bool m_skipBattlegrounds; + Optional<float> m_maxWalkableAngle; + Optional<float> m_maxWalkableAngleNotSteep; bool m_bigBaseUnit; + bool m_smallOutputSize; int32 m_mapid; diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index 2e9f3913edf..36df4e8f88b 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -99,6 +99,8 @@ bool handleArgs(int argc, char** argv, int &mapnum, int &tileX, int &tileY, + Optional<float>& maxAngle, + Optional<float>& maxAngleNotSteep, bool &skipLiquid, bool &skipContinents, bool &skipJunkMaps, @@ -106,6 +108,7 @@ bool handleArgs(int argc, char** argv, bool &debugOutput, bool &silent, bool &bigBaseUnit, + bool &smallOutputSize, char* &offMeshInputPath, char* &file, unsigned int& threads) @@ -113,7 +116,31 @@ bool handleArgs(int argc, char** argv, char* param = nullptr; for (int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "--threads") == 0) + if (strcmp(argv[i], "--maxAngle") == 0) + { + param = argv[++i]; + if (!param) + return false; + + float maxangle = atof(param); + if (maxangle <= 90.f && maxangle >= 0.f) + maxAngle = maxangle; + else + printf("invalid option for '--maxAngle', using default\n"); + } + else if (strcmp(argv[i], "--maxAngleNotSteep") == 0) + { + param = argv[++i]; + if (!param) + return false; + + float maxangle = atof(param); + if (maxangle <= 90.f && maxangle >= 0.f) + maxAngleNotSteep = maxangle; + else + printf("invalid option for '--maxAngleNotSteep', using default\n"); + } + else if (strcmp(argv[i], "--threads") == 0) { param = argv[++i]; if (!param) @@ -239,6 +266,10 @@ bool handleArgs(int argc, char** argv, offMeshInputPath = param; } + else if (strcmp(argv[i], "--smallOutputSize") == 0) + { + smallOutputSize = true; + } else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-?")) { printf("%s\n", Readme); @@ -341,20 +372,22 @@ int main(int argc, char** argv) unsigned int threads = std::thread::hardware_concurrency(); int mapnum = -1; int tileX = -1, tileY = -1; + Optional<float> maxAngle, maxAngleNotSteep; bool skipLiquid = false, skipContinents = false, skipJunkMaps = true, skipBattlegrounds = false, debugOutput = false, silent = false, - bigBaseUnit = false; + bigBaseUnit = false, + smallOutputSize = false; char* offMeshInputPath = nullptr; char* file = nullptr; bool validParam = handleArgs(argc, argv, mapnum, - tileX, tileY, + tileX, tileY, maxAngle, maxAngleNotSteep, skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds, - debugOutput, silent, bigBaseUnit, offMeshInputPath, file, threads); + debugOutput, silent, bigBaseUnit, smallOutputSize, offMeshInputPath, file, threads); if (!validParam) return silent ? -1 : finish("You have specified invalid parameters", -1); @@ -386,8 +419,8 @@ int main(int argc, char** argv) return itr != _liquidTypes.end() ? (1 << itr->second) : 0; }; - MapBuilder builder(skipLiquid, skipContinents, skipJunkMaps, - skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath); + MapBuilder builder(maxAngle, maxAngleNotSteep, skipLiquid, skipContinents, skipJunkMaps, + skipBattlegrounds, debugOutput, bigBaseUnit, smallOutputSize, mapnum, offMeshInputPath); uint32 start = getMSTime(); if (file) |