diff --git a/apps/navmeshtool/main.cpp b/apps/navmeshtool/main.cpp index 6cfa7fc61d..63effd41a2 100644 --- a/apps/navmeshtool/main.cpp +++ b/apps/navmeshtool/main.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -119,6 +120,10 @@ namespace NavMeshTool addOption("write-binary-log", bpo::value()->implicit_value(true)->default_value(false), "write progress in binary messages to be consumed by the launcher"); + addOption("worldspace-filter", bpo::value()->default_value(".*"), + "Regular expression to filter in specified worldspaces in modified ECMAScript grammar (see " + "https://en.cppreference.com/w/cpp/regex/ecmascript.html)"); + Files::ConfigurationManager::addCommonOptions(result); return result; @@ -180,6 +185,8 @@ namespace NavMeshTool const bool removeUnusedTiles = variables["remove-unused-tiles"].as(); const bool writeBinaryLog = variables["write-binary-log"].as(); + const std::regex worldspaceFilter(variables["worldspace-filter"].as()); + #ifdef WIN32 if (writeBinaryLog) _setmode(_fileno(stderr), _O_BINARY); @@ -229,8 +236,8 @@ namespace NavMeshTool navigatorSettings.mRecast.mSwimHeightScale = EsmLoader::getGameSetting(esmData.mGameSettings, "fSwimHeightScale").getFloat(); - WorldspaceData cellsData = gatherWorldspaceData( - navigatorSettings, readers, vfs, bulletShapeManager, esmData, processInteriorCells, writeBinaryLog); + WorldspaceData cellsData = gatherWorldspaceData(navigatorSettings, readers, vfs, bulletShapeManager, + esmData, processInteriorCells, writeBinaryLog, worldspaceFilter); const Status status = generateAllNavMeshTiles(agentBounds, navigatorSettings, threadsNumber, removeUnusedTiles, writeBinaryLog, cellsData, std::move(db)); diff --git a/apps/navmeshtool/worldspacedata.cpp b/apps/navmeshtool/worldspacedata.cpp index df5c48e7ab..43b3ae5da3 100644 --- a/apps/navmeshtool/worldspacedata.cpp +++ b/apps/navmeshtool/worldspacedata.cpp @@ -245,7 +245,7 @@ namespace NavMeshTool WorldspaceData gatherWorldspaceData(const DetourNavigator::Settings& settings, ESM::ReadersCache& readers, const VFS::Manager& vfs, Resource::BulletShapeManager& bulletShapeManager, const EsmLoader::EsmData& esmData, - bool processInteriorCells, bool writeBinaryLog) + bool processInteriorCells, bool writeBinaryLog, const std::regex& worldspaceFilter) { Log(Debug::Info) << "Processing " << esmData.mCells.size() << " cells..."; @@ -272,12 +272,23 @@ namespace NavMeshTool continue; } + const ESM::RefId cellWorldspace = cell.isExterior() ? ESM::Cell::sDefaultWorldspaceId : cell.mId; + + if (!std::regex_match(cellWorldspace.toString(), worldspaceFilter)) + { + Log(Debug::Info) << "Skipped filtered out" + << " cell (" << (i + 1) << "/" << esmData.mCells.size() << ") \"" + << cell.getDescription() << "\" from " << cellWorldspace << " worldspace"; + continue; + } + Log(Debug::Debug) << "Processing " << (exterior ? "exterior" : "interior") << " cell (" << (i + 1) << "/" - << esmData.mCells.size() << ") \"" << cell.getDescription() << "\""; + << esmData.mCells.size() << ") \"" << cell.getDescription() << "\" from " + << cellWorldspace << " worldspace"; const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY); const std::size_t cellObjectsBegin = data.mObjects.size(); - const ESM::RefId cellWorldspace = cell.isExterior() ? ESM::Cell::sDefaultWorldspaceId : cell.mId; + WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& { auto it = navMeshInputs.find(cellWorldspace); if (it == navMeshInputs.end()) @@ -354,8 +365,8 @@ namespace NavMeshTool serializeToStderr(ProcessedCells{ static_cast(i + 1) }); Log(Debug::Info) << "Processed " << (exterior ? "exterior" : "interior") << " cell (" << (i + 1) << "/" - << esmData.mCells.size() << ") " << cellDescription << " with " - << (data.mObjects.size() - cellObjectsBegin) << " objects"; + << esmData.mCells.size() << ") " << cellDescription << " from " << cellWorldspace + << " worldspace with " << (data.mObjects.size() - cellObjectsBegin) << " objects"; } data.mNavMeshInputs.reserve(navMeshInputs.size()); diff --git a/apps/navmeshtool/worldspacedata.hpp b/apps/navmeshtool/worldspacedata.hpp index 7096cf95ed..5a74a57342 100644 --- a/apps/navmeshtool/worldspacedata.hpp +++ b/apps/navmeshtool/worldspacedata.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include namespace ESM @@ -90,7 +90,7 @@ namespace NavMeshTool WorldspaceData gatherWorldspaceData(const DetourNavigator::Settings& settings, ESM::ReadersCache& readers, const VFS::Manager& vfs, Resource::BulletShapeManager& bulletShapeManager, const EsmLoader::EsmData& esmData, - bool processInteriorCells, bool writeBinaryLog); + bool processInteriorCells, bool writeBinaryLog, const std::regex& worldspaceFilter); } #endif