From 767a14587cbe86f0ef7db303134d83520767089d Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 20 Jul 2023 21:09:47 +0200 Subject: [PATCH] Add more debug logging on navmesh generation --- .../detournavigator/asyncnavmeshupdater.cpp | 22 ++++++++++++------- .../detournavigator/asyncnavmeshupdater.hpp | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index 89f75113e6..eb218c4681 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -339,7 +339,7 @@ namespace DetourNavigator switch (status) { case JobStatus::Done: - unlockTile(job->mAgentBounds, job->mChangedTile); + unlockTile(job->mId, job->mAgentBounds, job->mChangedTile); if (job->mGeneratedNavMeshData != nullptr) mDbWorker->enqueueJob(job); else @@ -565,12 +565,14 @@ namespace DetourNavigator mWaiting.pop_front(); + Log(Debug::Debug) << "Pop job " << job->mId << " by thread=" << std::this_thread::get_id(); + if (job->mRecastMesh != nullptr) 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; insertPrioritizedJob(job, mWaiting); return mJobs.end(); @@ -610,7 +612,7 @@ namespace DetourNavigator void AsyncNavMeshUpdater::repost(JobIt job) { - unlockTile(job->mAgentBounds, job->mChangedTile); + unlockTile(job->mId, job->mAgentBounds, job->mChangedTile); if (mShouldStop || job->mTryNumber > 2) return; @@ -628,17 +630,21 @@ namespace DetourNavigator 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; } - 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(); 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()) mProcessed.notify_all(); } diff --git a/components/detournavigator/asyncnavmeshupdater.hpp b/components/detournavigator/asyncnavmeshupdater.hpp index b759a8e9a6..9b95d4f4b3 100644 --- a/components/detournavigator/asyncnavmeshupdater.hpp +++ b/components/detournavigator/asyncnavmeshupdater.hpp @@ -199,9 +199,9 @@ namespace DetourNavigator 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;