Report stats for TileCachedRecastMeshManager

esm4-texture
elsid 7 months ago
parent c3d02c0b41
commit 9e2f3fd0b4
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -217,7 +217,10 @@ namespace DetourNavigator
Stats NavMeshManager::getStats() const Stats NavMeshManager::getStats() const
{ {
return Stats{ .mUpdater = mAsyncNavMeshUpdater.getStats() }; return Stats{
.mUpdater = mAsyncNavMeshUpdater.getStats(),
.mRecast = mRecastMeshManager.getStats(),
};
} }
RecastMeshTiles NavMeshManager::getRecastMeshTiles() const RecastMeshTiles NavMeshManager::getRecastMeshTiles() const

@ -32,11 +32,19 @@ namespace DetourNavigator
out.setAttribute(frameNumber, "NavMesh Cache Get", static_cast<double>(stats.mCache.mGetCount)); out.setAttribute(frameNumber, "NavMesh Cache Get", static_cast<double>(stats.mCache.mGetCount));
out.setAttribute(frameNumber, "NavMesh Cache Hit", static_cast<double>(stats.mCache.mHitCount)); out.setAttribute(frameNumber, "NavMesh Cache Hit", static_cast<double>(stats.mCache.mHitCount));
} }
void reportStats(const TileCachedRecastMeshManagerStats& stats, unsigned int frameNumber, osg::Stats& out)
{
out.setAttribute(frameNumber, "NavMesh Recast Tiles", static_cast<double>(stats.mTiles));
out.setAttribute(frameNumber, "NavMesh Recast Objects", static_cast<double>(stats.mObjects));
out.setAttribute(frameNumber, "NavMesh Recast Heightfields", static_cast<double>(stats.mHeightfields));
out.setAttribute(frameNumber, "NavMesh Recast Water", static_cast<double>(stats.mWater));
}
} }
void reportStats(const Stats& stats, unsigned int frameNumber, osg::Stats& out) void reportStats(const Stats& stats, unsigned int frameNumber, osg::Stats& out)
{ {
if (stats.mUpdater.has_value()) reportStats(stats.mUpdater, frameNumber, out);
reportStats(*stats.mUpdater, frameNumber, out); reportStats(stats.mRecast, frameNumber, out);
} }
} }

@ -50,9 +50,18 @@ namespace DetourNavigator
NavMeshTilesCacheStats mCache; NavMeshTilesCacheStats mCache;
}; };
struct TileCachedRecastMeshManagerStats
{
std::size_t mTiles = 0;
std::size_t mObjects = 0;
std::size_t mHeightfields = 0;
std::size_t mWater = 0;
};
struct Stats struct Stats
{ {
std::optional<AsyncNavMeshUpdaterStats> mUpdater; AsyncNavMeshUpdaterStats mUpdater;
TileCachedRecastMeshManagerStats mRecast;
}; };
void reportStats(const Stats& stats, unsigned int frameNumber, osg::Stats& out); void reportStats(const Stats& stats, unsigned int frameNumber, osg::Stats& out);

@ -1,8 +1,10 @@
#include "tilecachedrecastmeshmanager.hpp" #include "tilecachedrecastmeshmanager.hpp"
#include "changetype.hpp" #include "changetype.hpp"
#include "gettilespositions.hpp" #include "gettilespositions.hpp"
#include "recastmeshbuilder.hpp" #include "recastmeshbuilder.hpp"
#include "settingsutils.hpp" #include "settingsutils.hpp"
#include "stats.hpp"
#include "updateguard.hpp" #include "updateguard.hpp"
#include <components/bullethelpers/aabb.hpp> #include <components/bullethelpers/aabb.hpp>
@ -11,7 +13,6 @@
#include <boost/geometry/geometry.hpp> #include <boost/geometry/geometry.hpp>
#include <limits> #include <limits>
#include <vector>
namespace DetourNavigator namespace DetourNavigator
{ {
@ -429,6 +430,17 @@ namespace DetourNavigator
return std::move(mChangedTiles); return std::move(mChangedTiles);
} }
TileCachedRecastMeshManagerStats TileCachedRecastMeshManager::getStats() const
{
const std::lock_guard lock(mMutex);
return TileCachedRecastMeshManagerStats{
.mTiles = mCache.size(),
.mObjects = mObjects.size(),
.mHeightfields = mHeightfields.size(),
.mWater = mWater.size(),
};
}
TileCachedRecastMeshManager::IndexPoint TileCachedRecastMeshManager::makeIndexPoint( TileCachedRecastMeshManager::IndexPoint TileCachedRecastMeshManager::makeIndexPoint(
const TilePosition& tilePosition) const TilePosition& tilePosition)
{ {

@ -28,11 +28,11 @@
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <unordered_map> #include <unordered_map>
#include <vector>
namespace DetourNavigator namespace DetourNavigator
{ {
class RecastMesh; class RecastMesh;
struct TileCachedRecastMeshManagerStats;
class TileCachedRecastMeshManager class TileCachedRecastMeshManager
{ {
@ -81,6 +81,8 @@ namespace DetourNavigator
std::map<osg::Vec2i, ChangeType> takeChangedTiles(const UpdateGuard* guard); std::map<osg::Vec2i, ChangeType> takeChangedTiles(const UpdateGuard* guard);
TileCachedRecastMeshManagerStats getStats() const;
private: private:
struct Report struct Report
{ {

@ -119,6 +119,10 @@ namespace Resource
"NavMesh CachedTiles", "NavMesh CachedTiles",
"NavMesh Cache Get", "NavMesh Cache Get",
"NavMesh Cache Hit", "NavMesh Cache Hit",
"NavMesh Recast Tiles",
"NavMesh Recast Objects",
"NavMesh Recast Heightfields",
"NavMesh Recast Water",
}; };
std::vector<std::string> statNames; std::vector<std::string> statNames;

Loading…
Cancel
Save