diff options
author | UltraNix <80540499+UltraNix@users.noreply.github.com> | 2022-06-21 21:07:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-21 16:07:53 -0300 |
commit | 113bdacb5fba2034e236120d0631416a5d4670aa (patch) | |
tree | 4a4913deab07eab6a1a892a745dc06a013b7a5e6 /src/tools | |
parent | 73bd2b446ca40744db41e9c76537428e32a81596 (diff) |
fix(Core/Tools): Revert "Handle different slopes in mmaps and Add so… (#12111)
...me more input parameters to improve"
This reverts commit b544eb420ed54ba98fb0522f8814ce6b7e089094.
Fixes #12079
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 28 | ||||
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.h | 6 | ||||
-rw-r--r-- | src/tools/mmaps_generator/PathCommon.h | 2 | ||||
-rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 62 | ||||
-rw-r--r-- | src/tools/mmaps_generator/TerrainBuilder.cpp | 59 |
5 files changed, 46 insertions, 111 deletions
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index ece132630d..3ca17f2ed2 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -52,7 +52,7 @@ namespace MMAP m_workerThread.join(); } - MapBuilder::MapBuilder(Optional<float> maxWalkableAngle, Optional<float> maxWalkableAngleNotSteep, bool skipLiquid, + MapBuilder::MapBuilder(float maxWalkableAngle, bool skipLiquid, bool skipContinents, bool skipJunkMaps, bool skipBattlegrounds, bool debugOutput, bool bigBaseUnit, int mapid, const char* offMeshFilePath, unsigned int threads) : @@ -64,7 +64,6 @@ namespace MMAP m_skipBattlegrounds (skipBattlegrounds), m_skipLiquid (skipLiquid), m_maxWalkableAngle (maxWalkableAngle), - m_maxWalkableAngleNotSteep (maxWalkableAngleNotSteep), m_bigBaseUnit (bigBaseUnit), m_mapid (mapid), m_totalTiles (0u), @@ -654,16 +653,9 @@ namespace MMAP // mark all walkable tiles, both liquids and solids - /* we want to have triangles with slope less than walkableSlopeAngleNotSteep (<= 55) to have NAV_AREA_GROUND - * and with slope between walkableSlopeAngleNotSteep and walkableSlopeAngle (55 < .. <= 70) to have NAV_AREA_GROUND_STEEP. - * we achieve this using recast API: memset everything to NAV_AREA_GROUND_STEEP, call rcClearUnwalkableTriangles with 70 so - * any area above that will get RC_NULL_AREA (unwalkable), then call rcMarkWalkableTriangles with 55 to set NAV_AREA_GROUND - * on anything below 55 . Players and idle Creatures can use NAV_AREA_GROUND, while Creatures in combat can use NAV_AREA_GROUND_STEEP. - */ unsigned char* triFlags = new unsigned char[tTriCount]; - memset(triFlags, NAV_AREA_GROUND_STEEP, tTriCount * sizeof(unsigned char)); + memset(triFlags, NAV_GROUND, tTriCount * sizeof(unsigned char)); rcClearUnwalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngle, tVerts, tVertCount, tTris, tTriCount, triFlags); - rcMarkWalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngleNotSteep, tVerts, tVertCount, tTris, tTriCount, triFlags, NAV_AREA_GROUND); rcRasterizeTriangles(m_rcContext, tVerts, tVertCount, tTris, triFlags, tTriCount, *tile.solid, config.walkableClimb); delete[] triFlags; @@ -769,15 +761,8 @@ namespace MMAP // set polygons as walkable // TODO: special flags for DYNAMIC polygons, ie surfaces that can be turned on and off for (int i = 0; i < iv.polyMesh->npolys; ++i) - { - if (uint8 area = iv.polyMesh->areas[i] & NAV_AREA_ALL_MASK) - { - if (area >= NAV_AREA_MIN_VALUE) - iv.polyMesh->flags[i] = 1 << (NAV_AREA_MAX_VALUE - area); - else - iv.polyMesh->flags[i] = NAV_GROUND; // TODO: these will be dynamic in future - } - } + if (iv.polyMesh->areas[i] & RC_WALKABLE_AREA) + iv.polyMesh->flags[i] = iv.polyMesh->areas[i]; // setup mesh parameters dtNavMeshCreateParams params; @@ -1072,10 +1057,7 @@ namespace MMAP config.maxVertsPerPoly = DT_VERTS_PER_POLYGON; config.cs = tileConfig.BASE_UNIT_DIM; config.ch = tileConfig.BASE_UNIT_DIM; - // 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 : 55; - config.walkableSlopeAngleNotSteep = m_maxWalkableAngleNotSteep ? *m_maxWalkableAngleNotSteep : 55; + config.walkableSlopeAngle = m_maxWalkableAngle; 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 475469bf81..b4882557e4 100644 --- a/src/tools/mmaps_generator/MapBuilder.h +++ b/src/tools/mmaps_generator/MapBuilder.h @@ -147,8 +147,7 @@ namespace MMAP { friend class TileBuilder; public: - MapBuilder(Optional<float> maxWalkableAngle, - Optional<float> maxWalkableAngleNotSteep, + MapBuilder(float maxWalkableAngle, bool skipLiquid, bool skipContinents, bool skipJunkMaps, @@ -204,8 +203,7 @@ namespace MMAP bool m_skipBattlegrounds; bool m_skipLiquid; - Optional<float> m_maxWalkableAngle; - Optional<float> m_maxWalkableAngleNotSteep; + float m_maxWalkableAngle; bool m_bigBaseUnit; int32 m_mapid; diff --git a/src/tools/mmaps_generator/PathCommon.h b/src/tools/mmaps_generator/PathCommon.h index 36743eedb0..483b4783d9 100644 --- a/src/tools/mmaps_generator/PathCommon.h +++ b/src/tools/mmaps_generator/PathCommon.h @@ -105,7 +105,7 @@ namespace MMAP errno = 0; if ((dp = readdir(dirp)) != nullptr) { - if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0 && matchWildcardFilter(filter.c_str(), dp->d_name)) + if (matchWildcardFilter(filter.c_str(), dp->d_name)) fileList.emplace_back(dp->d_name); } else diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index 5407d99c08..83a6260aa4 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -17,26 +17,12 @@ #include "MapBuilder.h" #include "PathCommon.h" -#include "Timer.h" -#include "DBCFileLoader.h" -#include "PathCommon.h" #include "Util.h" +#include "Timer.h" #include <boost/filesystem.hpp> -#include <unordered_map> using namespace MMAP; -namespace -{ - std::unordered_map<uint32, uint8> _liquidTypes; -} - -uint32 GetLiquidFlags(uint32 liquidId) -{ - auto itr = _liquidTypes.find(liquidId); - return itr != _liquidTypes.end() ? (1 << itr->second) : 0; -} - bool checkDirectories(bool debugOutput) { std::vector<std::string> dirFiles; @@ -77,8 +63,7 @@ bool handleArgs(int argc, char** argv, int& mapnum, int& tileX, int& tileY, - Optional<float>& maxAngle, - Optional<float>& maxAngleNotSteep, + float& maxAngle, bool& skipLiquid, bool& skipContinents, bool& skipJunkMaps, @@ -100,23 +85,11 @@ bool handleArgs(int argc, char** argv, return false; float maxangle = atof(param); - if (maxangle <= 90.f && maxangle >= 0.f) + if (maxangle <= 90.f && maxangle >= 45.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]; @@ -266,29 +239,12 @@ int finish(const char* message, int returnValue) return returnValue; } -std::unordered_map<uint32, uint8> LoadLiquid() -{ - DBCFileLoader liquidDbc; - std::unordered_map<uint32, uint8> liquidData; - // format string doesnt matter as long as it has correct length (only used for mapping to structures in worldserver) - if (liquidDbc.Load((boost::filesystem::path("dbc") / "LiquidType.dbc").string().c_str(), "nxxixixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")) - { - for (uint32 x = 0; x < liquidDbc.GetNumRows(); ++x) - { - DBCFileLoader::Record record = liquidDbc.getRecord(x); - liquidData[record.getUInt(0)] = record.getUInt(3); - } - } - - return liquidData; -} - 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; + float maxAngle = 60.0f; bool skipLiquid = false, skipContinents = false, skipJunkMaps = true, @@ -300,7 +256,7 @@ int main(int argc, char** argv) char* file = nullptr; bool validParam = handleArgs(argc, argv, mapnum, - tileX, tileY, maxAngle, maxAngleNotSteep, + tileX, tileY, maxAngle, skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds, debugOutput, silent, bigBaseUnit, offMeshInputPath, file, threads); @@ -322,13 +278,7 @@ int main(int argc, char** argv) if (!checkDirectories(debugOutput)) return silent ? -3 : finish("Press ENTER to close...", -3); - _liquidTypes = LoadLiquid(); - if (_liquidTypes.empty()) - { - return silent ? -5 : finish("Failed to load LiquidType.dbc", -5); - } - - MapBuilder builder(maxAngle, maxAngleNotSteep, skipLiquid, skipContinents, skipJunkMaps, + MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath, threads); uint32 start = getMSTime(); diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp index 04e4ac76cd..ce791f0458 100644 --- a/src/tools/mmaps_generator/TerrainBuilder.cpp +++ b/src/tools/mmaps_generator/TerrainBuilder.cpp @@ -77,8 +77,6 @@ struct map_liquidHeader #define MAP_LIQUID_TYPE_SLIME 0x08 #define MAP_LIQUID_TYPE_DARK_WATER 0x10 -uint32 GetLiquidFlags(uint32 liquidId); - namespace MMAP { @@ -414,23 +412,27 @@ namespace MMAP else { liquidType = getLiquidType(i, liquid_flags); - if (liquidType & MAP_LIQUID_TYPE_DARK_WATER) - { - // players should not be here, so logically neither should creatures - useTerrain = false; - useLiquid = false; - } - else if ((liquidType & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)) != 0) - { - liquidType = NAV_AREA_WATER; - } - else if ((liquidType & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) != 0) + switch (liquidType) { - liquidType = NAV_AREA_MAGMA_SLIME; - } - else - { - useLiquid = false; + default: + useLiquid = false; + break; + case MAP_LIQUID_TYPE_WATER: + case MAP_LIQUID_TYPE_OCEAN: + // merge different types of water + liquidType = NAV_WATER; + break; + case MAP_LIQUID_TYPE_MAGMA: + liquidType = NAV_MAGMA; + break; + case MAP_LIQUID_TYPE_SLIME: + liquidType = NAV_SLIME; + break; + case MAP_LIQUID_TYPE_DARK_WATER: + // players should not be here, so logically neither should creatures + useTerrain = false; + useLiquid = false; + break; } } @@ -733,17 +735,20 @@ namespace MMAP vertsY = tilesY + 1; uint8* flags = liquid->GetFlagsStorage(); float* data = liquid->GetHeightStorage(); - uint8 type = NAV_AREA_EMPTY; + uint8 type = NAV_EMPTY; - // convert liquid type to NavTerrain - uint32 liquidFlags = GetLiquidFlags(liquid->GetType()); - if ((liquidFlags & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)) != 0) - { - type = NAV_AREA_WATER; - } - else if ((liquidFlags & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) != 0) + switch (liquid->GetType() & 3) { - type = NAV_AREA_MAGMA_SLIME; + case 0: + case 1: + type = NAV_WATER; + break; + case 2: + type = NAV_MAGMA; + break; + case 3: + type = NAV_SLIME; + break; } // indexing is weird... |