Add more debug logging on navmesh generation

revert-6246b479
elsid 1 year ago
parent 9817f4ca9a
commit 767a14587c
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -339,7 +339,7 @@ namespace DetourNavigator
switch (status) switch (status)
{ {
case JobStatus::Done: case JobStatus::Done:
unlockTile(job->mAgentBounds, job->mChangedTile); unlockTile(job->mId, job->mAgentBounds, job->mChangedTile);
if (job->mGeneratedNavMeshData != nullptr) if (job->mGeneratedNavMeshData != nullptr)
mDbWorker->enqueueJob(job); mDbWorker->enqueueJob(job);
else else
@ -565,12 +565,14 @@ namespace DetourNavigator
mWaiting.pop_front(); mWaiting.pop_front();
Log(Debug::Debug) << "Pop job " << job->mId << " by thread=" << std::this_thread::get_id();
if (job->mRecastMesh != nullptr) if (job->mRecastMesh != nullptr)
return job; return job;
if (!lockTile(job->mAgentBounds, job->mChangedTile)) if (!lockTile(job->mId, job->mAgentBounds, job->mChangedTile))
{ {
Log(Debug::Debug) << "Failed to lock tile by " << job->mId; Log(Debug::Debug) << "Failed to lock tile by job " << job->mId << " try=" << job->mTryNumber;
++job->mTryNumber; ++job->mTryNumber;
insertPrioritizedJob(job, mWaiting); insertPrioritizedJob(job, mWaiting);
return mJobs.end(); return mJobs.end();
@ -610,7 +612,7 @@ namespace DetourNavigator
void AsyncNavMeshUpdater::repost(JobIt job) void AsyncNavMeshUpdater::repost(JobIt job)
{ {
unlockTile(job->mAgentBounds, job->mChangedTile); unlockTile(job->mId, job->mAgentBounds, job->mChangedTile);
if (mShouldStop || job->mTryNumber > 2) if (mShouldStop || job->mTryNumber > 2)
return; return;
@ -628,17 +630,21 @@ namespace DetourNavigator
mJobs.erase(job); mJobs.erase(job);
} }
bool AsyncNavMeshUpdater::lockTile(const AgentBounds& agentBounds, const TilePosition& changedTile) bool AsyncNavMeshUpdater::lockTile(
std::size_t jobId, const AgentBounds& agentBounds, const TilePosition& changedTile)
{ {
Log(Debug::Debug) << "Locking tile agent=" << agentBounds << " changedTile=(" << changedTile << ")"; Log(Debug::Debug) << "Locking tile by job " << jobId << " agent=" << agentBounds << " changedTile=("
<< changedTile << ")";
return mProcessingTiles.lock()->emplace(agentBounds, changedTile).second; return mProcessingTiles.lock()->emplace(agentBounds, changedTile).second;
} }
void AsyncNavMeshUpdater::unlockTile(const AgentBounds& agentBounds, const TilePosition& changedTile) void AsyncNavMeshUpdater::unlockTile(
std::size_t jobId, const AgentBounds& agentBounds, const TilePosition& changedTile)
{ {
auto locked = mProcessingTiles.lock(); auto locked = mProcessingTiles.lock();
locked->erase(std::tie(agentBounds, changedTile)); locked->erase(std::tie(agentBounds, changedTile));
Log(Debug::Debug) << "Unlocked tile agent=" << agentBounds << " changedTile=(" << changedTile << ")"; Log(Debug::Debug) << "Unlocked tile by job " << jobId << " agent=" << agentBounds << " changedTile=("
<< changedTile << ")";
if (locked->empty()) if (locked->empty())
mProcessed.notify_all(); mProcessed.notify_all();
} }

@ -199,9 +199,9 @@ namespace DetourNavigator
void repost(JobIt job); void repost(JobIt job);
bool lockTile(const AgentBounds& agentBounds, const TilePosition& changedTile); bool lockTile(std::size_t jobId, const AgentBounds& agentBounds, const TilePosition& changedTile);
void unlockTile(const AgentBounds& agentBounds, const TilePosition& changedTile); void unlockTile(std::size_t jobId, const AgentBounds& agentBounds, const TilePosition& changedTile);
inline std::size_t getTotalJobs() const; inline std::size_t getTotalJobs() const;

Loading…
Cancel
Save