mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-03 04:14:00 +00:00
Add flag to filter worldspaces processed by navmeshtool
This commit is contained in:
parent
88e15e7246
commit
adcec8fded
3 changed files with 27 additions and 9 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
|
|
@ -119,6 +120,10 @@ namespace NavMeshTool
|
|||
addOption("write-binary-log", bpo::value<bool>()->implicit_value(true)->default_value(false),
|
||||
"write progress in binary messages to be consumed by the launcher");
|
||||
|
||||
addOption("worldspace-filter", bpo::value<std::string>()->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<bool>();
|
||||
const bool writeBinaryLog = variables["write-binary-log"].as<bool>();
|
||||
|
||||
const std::regex worldspaceFilter(variables["worldspace-filter"].as<std::string>());
|
||||
|
||||
#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));
|
||||
|
|
|
|||
|
|
@ -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<std::uint64_t>(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());
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <LinearMath/btVector3.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue