1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-29 18:32:36 +00:00
OpenMW/components/detournavigator/navmeshmanager.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
3.4 KiB
C++
Raw Normal View History

2018-03-14 01:49:08 +03:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
#include "asyncnavmeshupdater.hpp"
#include "offmeshconnectionsmanager.hpp"
2019-11-27 23:45:01 +01:00
#include "recastmeshtiles.hpp"
#include "waitconditiontype.hpp"
#include "heightfieldshape.hpp"
#include "agentbounds.hpp"
2018-03-14 01:49:08 +03:00
#include <osg/Vec3f>
#include <map>
#include <memory>
class dtNavMesh;
namespace DetourNavigator
{
class NavMeshManager
{
public:
class UpdateGuard
{
public:
explicit UpdateGuard(NavMeshManager& manager) : mImpl(manager.mRecastMeshManager) {}
friend const TileCachedRecastMeshManager::UpdateGuard* getImpl(const UpdateGuard* guard)
{
return guard == nullptr ? nullptr : &guard->mImpl;
}
private:
const TileCachedRecastMeshManager::UpdateGuard mImpl;
};
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
2018-03-14 01:49:08 +03:00
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
const AreaType areaType, const UpdateGuard* guard);
2018-03-14 01:49:08 +03:00
bool updateObject(ObjectId id, const btTransform& transform, AreaType areaType,
const UpdateGuard* guard);
2018-05-26 17:44:25 +03:00
void removeObject(const ObjectId id, const UpdateGuard* guard);
2018-03-14 01:49:08 +03:00
void addAgent(const AgentBounds& agentBounds);
void addWater(const osg::Vec2i& cellPosition, int cellSize, float level, const UpdateGuard* guard);
2018-07-20 22:11:34 +03:00
void removeWater(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
2018-07-20 22:11:34 +03:00
void addHeightfield(const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape,
const UpdateGuard* guard);
void removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
bool reset(const AgentBounds& agentBounds);
2018-03-14 01:49:08 +03:00
void addOffMeshConnection(const ObjectId id, const osg::Vec3f& start, const osg::Vec3f& end, const AreaType areaType);
void removeOffMeshConnections(const ObjectId id);
void update(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
2018-03-14 01:49:08 +03:00
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);
2018-03-14 01:49:08 +03:00
SharedNavMeshCacheItem getNavMesh(const AgentBounds& agentBounds) const;
2018-03-14 01:49:08 +03:00
std::map<AgentBounds, SharedNavMeshCacheItem> getNavMeshes() const;
Stats getStats() const;
2019-03-17 20:18:53 +03:00
RecastMeshTiles getRecastMeshTiles() const;
2019-11-27 23:45:01 +01:00
2018-03-14 01:49:08 +03:00
private:
const Settings& mSettings;
std::string mWorldspace;
2018-04-16 01:07:18 +03:00
TileCachedRecastMeshManager mRecastMeshManager;
OffMeshConnectionsManager mOffMeshConnectionsManager;
2018-03-14 01:49:08 +03:00
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
std::map<AgentBounds, SharedNavMeshCacheItem> mCache;
std::size_t mGenerationCounter = 0;
std::optional<TilePosition> mPlayerTile;
std::size_t mLastRecastMeshManagerRevision = 0;
inline SharedNavMeshCacheItem getCached(const AgentBounds& agentBounds) const;
inline void update(const AgentBounds& agentBounds, const TilePosition& playerTile,
const TilesPositionsRange& range, const SharedNavMeshCacheItem& cached,
const std::map<osg::Vec2i, ChangeType>& changedTiles);
2018-03-14 01:49:08 +03:00
};
}
#endif