#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H #include "oscillatingrecastmeshobject.hpp" #include "objectid.hpp" #include "version.hpp" #include #include #include #include #include #include #include class btCollisionShape; namespace DetourNavigator { struct Settings; class RecastMesh; struct RemovedRecastMeshObject { std::reference_wrapper mShape; btTransform mTransform; }; class RecastMeshManager { public: struct Water { int mCellSize = 0; btTransform mTransform; }; RecastMeshManager(const Settings& settings, const TileBounds& bounds, std::size_t generation); bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform, const AreaType areaType); bool updateObject(const ObjectId id, const btTransform& transform, const AreaType areaType); bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform); std::optional removeWater(const osg::Vec2i& cellPosition); std::optional removeObject(const ObjectId id); std::shared_ptr getMesh(); bool isEmpty() const; void reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion); Version getVersion() const; private: struct Report { std::size_t mRevision; Version mNavMeshVersion; }; const Settings& mSettings; const std::size_t mGeneration; const TileBounds mTileBounds; mutable std::mutex mMutex; std::size_t mRevision = 0; std::list mObjectsOrder; std::map::iterator> mObjects; std::list mWaterOrder; std::map::iterator> mWater; std::optional mLastNavMeshReportedChange; std::optional mLastNavMeshReport; }; } #endif