mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Count navmesh cache hit rate
This commit is contained in:
parent
94e8855c8c
commit
88ca4a1db6
@ -53,13 +53,16 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
NavMeshTilesCache::NavMeshTilesCache(const std::size_t maxNavMeshDataSize)
|
||||
: mMaxNavMeshDataSize(maxNavMeshDataSize), mUsedNavMeshDataSize(0), mFreeNavMeshDataSize(0) {}
|
||||
: mMaxNavMeshDataSize(maxNavMeshDataSize), mUsedNavMeshDataSize(0), mFreeNavMeshDataSize(0),
|
||||
mHitCount(0), mGetCount(0){}
|
||||
|
||||
NavMeshTilesCache::Value NavMeshTilesCache::get(const osg::Vec3f& agentHalfExtents, const TilePosition& changedTile,
|
||||
const RecastMesh& recastMesh, const std::vector<OffMeshConnection>& offMeshConnections)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
++mGetCount;
|
||||
|
||||
const auto agentValues = mValues.find(agentHalfExtents);
|
||||
if (agentValues == mValues.end())
|
||||
return Value();
|
||||
@ -74,6 +77,8 @@ namespace DetourNavigator
|
||||
|
||||
acquireItemUnsafe(tile->second);
|
||||
|
||||
++mHitCount;
|
||||
|
||||
return Value(*this, tile->second);
|
||||
}
|
||||
|
||||
@ -123,17 +128,22 @@ namespace DetourNavigator
|
||||
std::size_t navMeshCacheSize = 0;
|
||||
std::size_t usedNavMeshTiles = 0;
|
||||
std::size_t cachedNavMeshTiles = 0;
|
||||
std::size_t hitCount = 0;
|
||||
std::size_t getCount = 0;
|
||||
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mMutex);
|
||||
navMeshCacheSize = mUsedNavMeshDataSize;
|
||||
usedNavMeshTiles = mBusyItems.size();
|
||||
cachedNavMeshTiles = mFreeItems.size();
|
||||
hitCount = mHitCount;
|
||||
getCount = mGetCount;
|
||||
}
|
||||
|
||||
stats.setAttribute(frameNumber, "NavMesh CacheSize", navMeshCacheSize);
|
||||
stats.setAttribute(frameNumber, "NavMesh UsedTiles", usedNavMeshTiles);
|
||||
stats.setAttribute(frameNumber, "NavMesh CachedTiles", cachedNavMeshTiles);
|
||||
stats.setAttribute(frameNumber, "NavMesh CacheHitRate", static_cast<double>(hitCount) / getCount * 100.0);
|
||||
}
|
||||
|
||||
void NavMeshTilesCache::removeLeastRecentlyUsed()
|
||||
|
@ -194,6 +194,8 @@ namespace DetourNavigator
|
||||
std::size_t mMaxNavMeshDataSize;
|
||||
std::size_t mUsedNavMeshDataSize;
|
||||
std::size_t mFreeNavMeshDataSize;
|
||||
std::size_t mHitCount;
|
||||
std::size_t mGetCount;
|
||||
std::list<Item> mBusyItems;
|
||||
std::list<Item> mFreeItems;
|
||||
std::map<osg::Vec3f, std::map<TilePosition, TileMap>> mValues;
|
||||
|
@ -394,6 +394,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase *viewer)
|
||||
"NavMesh CacheSize",
|
||||
"NavMesh UsedTiles",
|
||||
"NavMesh CachedTiles",
|
||||
"NavMesh CacheHitRate",
|
||||
"",
|
||||
"Mechanics Actors",
|
||||
"Mechanics Objects",
|
||||
|
Loading…
Reference in New Issue
Block a user