2018-03-13 22:49:08 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
|
|
|
|
|
|
|
|
#include "asyncnavmeshupdater.hpp"
|
|
|
|
#include "cachedrecastmeshmanager.hpp"
|
2018-08-26 20:27:38 +00:00
|
|
|
#include "offmeshconnectionsmanager.hpp"
|
2018-04-01 17:24:02 +00:00
|
|
|
#include "sharednavmesh.hpp"
|
2019-11-27 22:45:01 +00:00
|
|
|
#include "recastmeshtiles.hpp"
|
2018-04-01 17:24:02 +00:00
|
|
|
|
|
|
|
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class dtNavMesh;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class NavMeshManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NavMeshManager(const Settings& settings);
|
|
|
|
|
2018-09-22 15:36:57 +00:00
|
|
|
bool addObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform,
|
2018-07-18 19:09:50 +00:00
|
|
|
const AreaType areaType);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2018-09-22 15:36:57 +00:00
|
|
|
bool updateObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform,
|
2018-07-18 19:09:50 +00:00
|
|
|
const AreaType areaType);
|
2018-05-26 14:44:25 +00:00
|
|
|
|
2018-09-22 15:36:57 +00:00
|
|
|
bool removeObject(const ObjectId id);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2018-04-01 17:24:02 +00:00
|
|
|
void addAgent(const osg::Vec3f& agentHalfExtents);
|
|
|
|
|
2018-07-20 19:11:34 +00:00
|
|
|
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
|
|
|
|
|
|
|
|
bool removeWater(const osg::Vec2i& cellPosition);
|
|
|
|
|
2019-03-10 11:36:16 +00:00
|
|
|
bool reset(const osg::Vec3f& agentHalfExtents);
|
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
|
|
|
|
2018-04-01 17:24:02 +00:00
|
|
|
void update(osg::Vec3f playerPosition, const osg::Vec3f& agentHalfExtents);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2021-05-05 16:13:17 +00:00
|
|
|
void wait(Loading::Listener& listener);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2018-09-30 22:33:25 +00:00
|
|
|
SharedNavMeshCacheItem getNavMesh(const osg::Vec3f& agentHalfExtents) const;
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2018-09-30 22:33:25 +00:00
|
|
|
std::map<osg::Vec3f, SharedNavMeshCacheItem> getNavMeshes() const;
|
2018-04-07 13:11:23 +00:00
|
|
|
|
2019-03-17 17:18:53 +00:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
|
|
|
|
|
2019-11-27 22:45:01 +00:00
|
|
|
RecastMeshTiles getRecastMeshTiles();
|
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
private:
|
2018-04-01 00:44:16 +00:00
|
|
|
const Settings& mSettings;
|
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;
|
2018-09-30 22:33:25 +00:00
|
|
|
std::map<osg::Vec3f, SharedNavMeshCacheItem> mCache;
|
|
|
|
std::map<osg::Vec3f, std::map<TilePosition, ChangeType>> mChangedTiles;
|
2018-04-21 13:09:49 +00:00
|
|
|
std::size_t mGenerationCounter = 0;
|
2018-08-30 22:39:44 +00:00
|
|
|
std::map<osg::Vec3f, TilePosition> mPlayerTile;
|
|
|
|
std::map<osg::Vec3f, std::size_t> mLastRecastMeshManagerRevision;
|
2018-04-01 00:44:16 +00:00
|
|
|
|
2018-07-14 12:05:28 +00:00
|
|
|
void addChangedTiles(const btCollisionShape& shape, const btTransform& transform, const ChangeType changeType);
|
2018-04-01 17:24:02 +00:00
|
|
|
|
2018-07-20 19:11:34 +00:00
|
|
|
void addChangedTiles(const int cellSize, const btTransform& transform, const ChangeType changeType);
|
|
|
|
|
|
|
|
void addChangedTile(const TilePosition& tilePosition, const ChangeType changeType);
|
|
|
|
|
2019-02-16 12:32:47 +00:00
|
|
|
SharedNavMeshCacheItem getCached(const osg::Vec3f& agentHalfExtents) const;
|
2018-03-13 22:49:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|