Store weak pointers to navmesh in jobs queue

To avoid useless processing for removed navmeshes.
pull/541/head
elsid 6 years ago
parent ccc709a316
commit f6a1d3cecf
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -129,12 +129,17 @@ namespace DetourNavigator
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 playerTile = *mPlayerTile.lockConst();
const auto offMeshConnections = mOffMeshConnectionsManager.get().get(job.mChangedTile);
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();
@ -143,7 +148,7 @@ namespace DetourNavigator
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,
" generation=", locked->getGeneration(),
" revision=", locked->getNavMeshRevision(),
@ -194,7 +199,8 @@ namespace DetourNavigator
writeToFile(*recastMesh, mSettings.get().mRecastMeshPathPrefix + std::to_string(job.mChangedTile.x())
+ "_" + std::to_string(job.mChangedTile.y()) + "_", recastMeshRevision);
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)

@ -48,7 +48,7 @@ namespace DetourNavigator
struct Job
{
osg::Vec3f mAgentHalfExtents;
SharedNavMeshCacheItem mNavMeshCacheItem;
std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem;
TilePosition mChangedTile;
unsigned mTryNumber;
ChangeType mChangeType;

Loading…
Cancel
Save