#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H #include "asyncnavmeshupdater.hpp" #include "cachedrecastmeshmanager.hpp" #include #include #include #include class dtNavMesh; namespace DetourNavigator { using NavMeshConstPtr = std::shared_ptr; class NavMeshManager { public: NavMeshManager(const Settings& settings); template bool addObject(std::size_t id, const T& shape, const btTransform& transform) { if (!mRecastMeshManager.addObject(id, shape, transform)) return false; ++mRevision; addChangedTiles(shape, transform); return true; } bool removeObject(std::size_t id); void reset(const osg::Vec3f& agentHalfExtents); void update(const osg::Vec3f& agentHalfExtents); void wait(); NavMeshConstPtr getNavMesh(const osg::Vec3f& agentHalfExtents) const; private: std::size_t mRevision = 0; const Settings& mSettings; CachedRecastMeshManager mRecastMeshManager; std::map> mCache; std::map> mChangedTiles; AsyncNavMeshUpdater mAsyncNavMeshUpdater; void addChangedTiles(const btCollisionShape& shape, const btTransform& transform); }; } #endif