1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00
OpenMW/components/detournavigator/navmeshmanager.hpp

88 lines
3.1 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 "cachedrecastmeshmanager.hpp"
#include "offmeshconnectionsmanager.hpp"
2019-11-27 23:45:01 +01:00
#include "recastmeshtiles.hpp"
#include "waitconditiontype.hpp"
#include "heightfieldshape.hpp"
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
2018-03-14 01:49:08 +03:00
#include <osg/Vec3f>
#include <map>
#include <memory>
class dtNavMesh;
namespace DetourNavigator
{
class NavMeshManager
{
public:
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
void setWorldspace(std::string_view worldspace);
2018-03-14 01:49:08 +03:00
bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
2018-07-18 22:09:50 +03:00
const AreaType areaType);
2018-03-14 01:49:08 +03:00
bool updateObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
2018-07-18 22:09:50 +03:00
const AreaType areaType);
2018-05-26 17:44:25 +03:00
2018-09-22 18:36:57 +03:00
bool removeObject(const ObjectId id);
2018-03-14 01:49:08 +03:00
void addAgent(const osg::Vec3f& agentHalfExtents);
2021-11-04 02:48:32 +01:00
bool addWater(const osg::Vec2i& cellPosition, int cellSize, float level);
2018-07-20 22:11:34 +03:00
bool removeWater(const osg::Vec2i& cellPosition);
2021-11-04 03:19:41 +01:00
bool addHeightfield(const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape);
bool removeHeightfield(const osg::Vec2i& cellPosition);
bool reset(const osg::Vec3f& agentHalfExtents);
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);
2021-06-23 23:13:59 +02:00
void update(const osg::Vec3f& playerPosition, const osg::Vec3f& agentHalfExtents);
2018-03-14 01:49:08 +03:00
void wait(Loading::Listener& listener, WaitConditionType waitConditionType);
2018-03-14 01:49:08 +03:00
SharedNavMeshCacheItem getNavMesh(const osg::Vec3f& agentHalfExtents) const;
2018-03-14 01:49:08 +03:00
std::map<osg::Vec3f, SharedNavMeshCacheItem> getNavMeshes() const;
2019-03-17 20:18:53 +03:00
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
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<osg::Vec3f, SharedNavMeshCacheItem> mCache;
std::map<osg::Vec3f, std::map<TilePosition, ChangeType>> mChangedTiles;
std::size_t mGenerationCounter = 0;
std::map<osg::Vec3f, TilePosition> mPlayerTile;
std::map<osg::Vec3f, std::size_t> mLastRecastMeshManagerRevision;
void addChangedTiles(const btCollisionShape& shape, const btTransform& transform, const ChangeType changeType);
2021-11-04 03:19:41 +01:00
void addChangedTiles(const int cellSize, const btVector3& shift, const ChangeType changeType);
2018-07-20 22:11:34 +03:00
void addChangedTile(const TilePosition& tilePosition, const ChangeType changeType);
SharedNavMeshCacheItem getCached(const osg::Vec3f& agentHalfExtents) const;
2018-03-14 01:49:08 +03:00
};
}
#endif