mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Store weak pointers to navmesh in jobs queue
To avoid useless processing for removed navmeshes.
This commit is contained in:
parent
ccc709a316
commit
f6a1d3cecf
2 changed files with 10 additions and 4 deletions
|
@ -129,12 +129,17 @@ namespace DetourNavigator
|
||||||
|
|
||||||
const auto firstStart = setFirstStart(start);
|
const auto firstStart = setFirstStart(start);
|
||||||
|
|
||||||
|
const auto navMeshCacheItem = job.mNavMeshCacheItem.lock();
|
||||||
|
|
||||||
|
if (!navMeshCacheItem)
|
||||||
|
return true;
|
||||||
|
|
||||||
const auto recastMesh = mRecastMeshManager.get().getMesh(job.mChangedTile);
|
const auto recastMesh = mRecastMeshManager.get().getMesh(job.mChangedTile);
|
||||||
const auto playerTile = *mPlayerTile.lockConst();
|
const auto playerTile = *mPlayerTile.lockConst();
|
||||||
const auto offMeshConnections = mOffMeshConnectionsManager.get().get(job.mChangedTile);
|
const auto offMeshConnections = mOffMeshConnectionsManager.get().get(job.mChangedTile);
|
||||||
|
|
||||||
const auto status = updateNavMesh(job.mAgentHalfExtents, recastMesh.get(), job.mChangedTile, playerTile,
|
const auto status = updateNavMesh(job.mAgentHalfExtents, recastMesh.get(), job.mChangedTile, playerTile,
|
||||||
offMeshConnections, mSettings, job.mNavMeshCacheItem, mNavMeshTilesCache);
|
offMeshConnections, mSettings, navMeshCacheItem, mNavMeshTilesCache);
|
||||||
|
|
||||||
const auto finish = std::chrono::steady_clock::now();
|
const auto finish = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
@ -143,7 +148,7 @@ namespace DetourNavigator
|
||||||
using FloatMs = std::chrono::duration<float, std::milli>;
|
using FloatMs = std::chrono::duration<float, std::milli>;
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto locked = job.mNavMeshCacheItem->lockConst();
|
const auto locked = navMeshCacheItem->lockConst();
|
||||||
log("cache updated for agent=", job.mAgentHalfExtents, " status=", status,
|
log("cache updated for agent=", job.mAgentHalfExtents, " status=", status,
|
||||||
" generation=", locked->getGeneration(),
|
" generation=", locked->getGeneration(),
|
||||||
" revision=", locked->getNavMeshRevision(),
|
" revision=", locked->getNavMeshRevision(),
|
||||||
|
@ -194,7 +199,8 @@ namespace DetourNavigator
|
||||||
writeToFile(*recastMesh, mSettings.get().mRecastMeshPathPrefix + std::to_string(job.mChangedTile.x())
|
writeToFile(*recastMesh, mSettings.get().mRecastMeshPathPrefix + std::to_string(job.mChangedTile.x())
|
||||||
+ "_" + std::to_string(job.mChangedTile.y()) + "_", recastMeshRevision);
|
+ "_" + std::to_string(job.mChangedTile.y()) + "_", recastMeshRevision);
|
||||||
if (mSettings.get().mEnableWriteNavMeshToFile)
|
if (mSettings.get().mEnableWriteNavMeshToFile)
|
||||||
writeToFile(job.mNavMeshCacheItem->lockConst()->getValue(), mSettings.get().mNavMeshPathPrefix, navMeshRevision);
|
if (const auto shared = job.mNavMeshCacheItem.lock())
|
||||||
|
writeToFile(shared->lockConst()->getValue(), mSettings.get().mNavMeshPathPrefix, navMeshRevision);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point AsyncNavMeshUpdater::setFirstStart(const std::chrono::steady_clock::time_point& value)
|
std::chrono::steady_clock::time_point AsyncNavMeshUpdater::setFirstStart(const std::chrono::steady_clock::time_point& value)
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace DetourNavigator
|
||||||
struct Job
|
struct Job
|
||||||
{
|
{
|
||||||
osg::Vec3f mAgentHalfExtents;
|
osg::Vec3f mAgentHalfExtents;
|
||||||
SharedNavMeshCacheItem mNavMeshCacheItem;
|
std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem;
|
||||||
TilePosition mChangedTile;
|
TilePosition mChangedTile;
|
||||||
unsigned mTryNumber;
|
unsigned mTryNumber;
|
||||||
ChangeType mChangeType;
|
ChangeType mChangeType;
|
||||||
|
|
Loading…
Reference in a new issue