2018-03-13 22:49:08 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
|
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
#include "agentbounds.hpp"
|
2018-03-13 22:49:08 +00:00
|
|
|
#include "asyncnavmeshupdater.hpp"
|
2024-05-19 13:59:12 +00:00
|
|
|
#include "cellgridbounds.hpp"
|
2021-07-14 18:57:52 +00:00
|
|
|
#include "heightfieldshape.hpp"
|
2018-08-26 20:27:38 +00:00
|
|
|
#include "offmeshconnectionsmanager.hpp"
|
2019-11-27 22:45:01 +00:00
|
|
|
#include "recastmeshtiles.hpp"
|
2021-05-14 19:06:29 +00:00
|
|
|
#include "waitconditiontype.hpp"
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class dtNavMesh;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class NavMeshManager
|
|
|
|
{
|
|
|
|
public:
|
2021-07-09 20:51:42 +00:00
|
|
|
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
|
|
|
|
|
2023-04-20 23:45:21 +00:00
|
|
|
ScopedUpdateGuard makeUpdateGuard() { return mRecastMeshManager.makeUpdateGuard(); }
|
|
|
|
|
2024-05-19 13:59:12 +00:00
|
|
|
void updateBounds(ESM::RefId worldspace, const std::optional<CellGridBounds>& cellGridBounds,
|
|
|
|
const osg::Vec3f& playerPosition, const UpdateGuard* guard);
|
2022-02-01 00:21:47 +00:00
|
|
|
|
2021-08-01 00:13:55 +00:00
|
|
|
bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
|
2022-09-05 07:23:14 +00:00
|
|
|
const AreaType areaType, const UpdateGuard* guard);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
bool updateObject(ObjectId id, const btTransform& transform, AreaType areaType, const UpdateGuard* guard);
|
2018-05-26 14:44:25 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void removeObject(const ObjectId id, const UpdateGuard* guard);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
void addAgent(const AgentBounds& agentBounds);
|
2018-04-01 17:24:02 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void addWater(const osg::Vec2i& cellPosition, int cellSize, float level, const UpdateGuard* guard);
|
2018-07-20 19:11:34 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void removeWater(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
|
2018-07-20 19:11:34 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void addHeightfield(
|
|
|
|
const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape, const UpdateGuard* guard);
|
2021-07-14 18:57:52 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
|
2021-07-14 18:57:52 +00:00
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
bool reset(const AgentBounds& agentBounds);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2020-06-11 21:23:30 +00:00
|
|
|
void addOffMeshConnection(
|
|
|
|
const ObjectId id, const osg::Vec3f& start, const osg::Vec3f& end, const AreaType areaType);
|
2018-08-26 20:27:38 +00:00
|
|
|
|
2020-06-11 21:23:30 +00:00
|
|
|
void removeOffMeshConnections(const ObjectId id);
|
2018-08-26 20:27:38 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void update(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2022-09-05 07:23:14 +00:00
|
|
|
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
SharedNavMeshCacheItem getNavMesh(const AgentBounds& agentBounds) const;
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
std::map<AgentBounds, SharedNavMeshCacheItem> getNavMeshes() const;
|
2018-04-07 13:11:23 +00:00
|
|
|
|
2022-08-28 12:52:12 +00:00
|
|
|
Stats getStats() const;
|
2019-03-17 17:18:53 +00:00
|
|
|
|
2021-10-09 16:36:37 +00:00
|
|
|
RecastMeshTiles getRecastMeshTiles() const;
|
2019-11-27 22:45:01 +00:00
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
private:
|
2018-04-01 00:44:16 +00:00
|
|
|
const Settings& mSettings;
|
2024-05-19 13:59:12 +00:00
|
|
|
const int mMaxRadius;
|
2024-05-19 12:26:28 +00:00
|
|
|
ESM::RefId mWorldspace;
|
2024-05-19 13:59:12 +00:00
|
|
|
std::optional<CellGridBounds> mCellGridBounds;
|
2018-04-15 22:07:18 +00:00
|
|
|
TileCachedRecastMeshManager mRecastMeshManager;
|
2018-08-26 20:27:38 +00:00
|
|
|
OffMeshConnectionsManager mOffMeshConnectionsManager;
|
2018-03-13 22:49:08 +00:00
|
|
|
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
|
2022-06-16 22:28:44 +00:00
|
|
|
std::map<AgentBounds, SharedNavMeshCacheItem> mCache;
|
2018-04-21 13:09:49 +00:00
|
|
|
std::size_t mGenerationCounter = 0;
|
2022-08-26 18:33:34 +00:00
|
|
|
std::optional<TilePosition> mPlayerTile;
|
|
|
|
std::size_t mLastRecastMeshManagerRevision = 0;
|
2018-04-01 00:44:16 +00:00
|
|
|
|
2022-08-26 18:33:34 +00:00
|
|
|
inline SharedNavMeshCacheItem getCached(const AgentBounds& agentBounds) const;
|
2018-04-01 17:24:02 +00:00
|
|
|
|
2022-08-26 18:33:34 +00:00
|
|
|
inline void update(const AgentBounds& agentBounds, const TilePosition& playerTile,
|
2022-08-28 14:43:43 +00:00
|
|
|
const TilesPositionsRange& range, const SharedNavMeshCacheItem& cached,
|
|
|
|
const std::map<osg::Vec2i, ChangeType>& changedTiles);
|
2018-03-13 22:49:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|