mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 20:29:57 +00:00
Support multiple threads for async nav mesh updater
This commit is contained in:
parent
7c5bedc35a
commit
7c80bb9411
6 changed files with 11 additions and 3 deletions
|
@ -215,6 +215,7 @@ namespace MWWorld
|
||||||
navigatorSettings.mRegionMergeSize = Settings::Manager::getInt("region merge size", "Navigator");
|
navigatorSettings.mRegionMergeSize = Settings::Manager::getInt("region merge size", "Navigator");
|
||||||
navigatorSettings.mRegionMinSize = Settings::Manager::getInt("region min size", "Navigator");
|
navigatorSettings.mRegionMinSize = Settings::Manager::getInt("region min size", "Navigator");
|
||||||
navigatorSettings.mTileSize = Settings::Manager::getInt("tile size", "Navigator");
|
navigatorSettings.mTileSize = Settings::Manager::getInt("tile size", "Navigator");
|
||||||
|
navigatorSettings.mAsyncNavMeshUpdaterThreads = static_cast<std::size_t>(Settings::Manager::getInt("async nav mesh updater threads", "Navigator"));
|
||||||
navigatorSettings.mMaxPolygonPathSize = static_cast<std::size_t>(Settings::Manager::getInt("max polygon path size", "Navigator"));
|
navigatorSettings.mMaxPolygonPathSize = static_cast<std::size_t>(Settings::Manager::getInt("max polygon path size", "Navigator"));
|
||||||
navigatorSettings.mMaxSmoothPathSize = static_cast<std::size_t>(Settings::Manager::getInt("max smooth path size", "Navigator"));
|
navigatorSettings.mMaxSmoothPathSize = static_cast<std::size_t>(Settings::Manager::getInt("max smooth path size", "Navigator"));
|
||||||
navigatorSettings.mTrianglesPerChunk = static_cast<std::size_t>(Settings::Manager::getInt("triangles per chunk", "Navigator"));
|
navigatorSettings.mTrianglesPerChunk = static_cast<std::size_t>(Settings::Manager::getInt("triangles per chunk", "Navigator"));
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace
|
||||||
mSettings.mRegionMergeSize = 20;
|
mSettings.mRegionMergeSize = 20;
|
||||||
mSettings.mRegionMinSize = 8;
|
mSettings.mRegionMinSize = 8;
|
||||||
mSettings.mTileSize = 64;
|
mSettings.mTileSize = 64;
|
||||||
|
mSettings.mAsyncNavMeshUpdaterThreads = 1;
|
||||||
mSettings.mMaxPolygonPathSize = 1024;
|
mSettings.mMaxPolygonPathSize = 1024;
|
||||||
mSettings.mMaxSmoothPathSize = 1024;
|
mSettings.mMaxSmoothPathSize = 1024;
|
||||||
mSettings.mTrianglesPerChunk = 256;
|
mSettings.mTrianglesPerChunk = 256;
|
||||||
|
|
|
@ -52,8 +52,9 @@ namespace DetourNavigator
|
||||||
, mRecastMeshManager(recastMeshManager)
|
, mRecastMeshManager(recastMeshManager)
|
||||||
, mOffMeshConnectionsManager(offMeshConnectionsManager)
|
, mOffMeshConnectionsManager(offMeshConnectionsManager)
|
||||||
, mShouldStop()
|
, mShouldStop()
|
||||||
, mThread([&] { process(); })
|
|
||||||
{
|
{
|
||||||
|
for (std::size_t i = 0; i < mSettings.get().mAsyncNavMeshUpdaterThreads; ++i)
|
||||||
|
mThreads.emplace_back([&] { process(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncNavMeshUpdater::~AsyncNavMeshUpdater()
|
AsyncNavMeshUpdater::~AsyncNavMeshUpdater()
|
||||||
|
@ -63,7 +64,8 @@ namespace DetourNavigator
|
||||||
mJobs = decltype(mJobs)();
|
mJobs = decltype(mJobs)();
|
||||||
mHasJob.notify_all();
|
mHasJob.notify_all();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
mThread.join();
|
for (auto& thread : mThreads)
|
||||||
|
thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncNavMeshUpdater::post(const osg::Vec3f& agentHalfExtents,
|
void AsyncNavMeshUpdater::post(const osg::Vec3f& agentHalfExtents,
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace DetourNavigator
|
||||||
TilePosition mPlayerTile;
|
TilePosition mPlayerTile;
|
||||||
std::mutex mFirstStartMutex;
|
std::mutex mFirstStartMutex;
|
||||||
boost::optional<std::chrono::steady_clock::time_point> mFirstStart;
|
boost::optional<std::chrono::steady_clock::time_point> mFirstStart;
|
||||||
std::thread mThread;
|
std::vector<std::thread> mThreads;
|
||||||
|
|
||||||
void process() throw();
|
void process() throw();
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace DetourNavigator
|
||||||
int mRegionMergeSize;
|
int mRegionMergeSize;
|
||||||
int mRegionMinSize;
|
int mRegionMinSize;
|
||||||
int mTileSize;
|
int mTileSize;
|
||||||
|
std::size_t mAsyncNavMeshUpdaterThreads;
|
||||||
std::size_t mMaxPolygonPathSize;
|
std::size_t mMaxPolygonPathSize;
|
||||||
std::size_t mMaxSmoothPathSize;
|
std::size_t mMaxSmoothPathSize;
|
||||||
std::size_t mTrianglesPerChunk;
|
std::size_t mTrianglesPerChunk;
|
||||||
|
|
|
@ -585,6 +585,9 @@ region merge size = 20
|
||||||
# The minimum number of cells allowed to form isolated island areas. (value >= 0)
|
# The minimum number of cells allowed to form isolated island areas. (value >= 0)
|
||||||
region min size = 8
|
region min size = 8
|
||||||
|
|
||||||
|
# Number of background threads to update nav mesh (value >= 1)
|
||||||
|
async nav mesh updater threads = 1
|
||||||
|
|
||||||
# Maximum size of path over polygons (value > 0)
|
# Maximum size of path over polygons (value > 0)
|
||||||
max polygon path size = 1024
|
max polygon path size = 1024
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue