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"
|
2018-04-01 20:24:02 +03:00
|
|
|
#include "sharednavmesh.hpp"
|
|
|
|
|
|
|
|
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-04-01 03:44:16 +03:00
|
|
|
#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:
|
|
|
|
NavMeshManager(const Settings& settings);
|
|
|
|
|
2018-07-12 11:44:11 +03:00
|
|
|
bool addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform,
|
2018-07-18 22:09:50 +03:00
|
|
|
const AreaType areaType);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-07-12 11:44:11 +03:00
|
|
|
bool updateObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform,
|
2018-07-18 22:09:50 +03:00
|
|
|
const AreaType areaType);
|
2018-05-26 17:44:25 +03:00
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
bool removeObject(std::size_t id);
|
|
|
|
|
2018-04-01 20:24:02 +03:00
|
|
|
void addAgent(const osg::Vec3f& agentHalfExtents);
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
void reset(const osg::Vec3f& agentHalfExtents);
|
|
|
|
|
2018-04-01 20:24:02 +03:00
|
|
|
void update(osg::Vec3f playerPosition, const osg::Vec3f& agentHalfExtents);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
void wait();
|
|
|
|
|
2018-04-01 20:24:02 +03:00
|
|
|
SharedNavMesh getNavMesh(const osg::Vec3f& agentHalfExtents) const;
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-04-07 16:11:23 +03:00
|
|
|
std::map<osg::Vec3f, std::shared_ptr<NavMeshCacheItem>> getNavMeshes() const;
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
private:
|
2018-04-01 03:44:16 +03:00
|
|
|
const Settings& mSettings;
|
2018-04-16 01:07:18 +03:00
|
|
|
TileCachedRecastMeshManager mRecastMeshManager;
|
2018-03-14 01:49:08 +03:00
|
|
|
std::map<osg::Vec3f, std::shared_ptr<NavMeshCacheItem>> mCache;
|
2018-07-14 15:05:28 +03:00
|
|
|
std::map<osg::Vec3f, std::map<TilePosition, ChangeType>> mChangedTiles;
|
2018-03-14 01:49:08 +03:00
|
|
|
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
|
2018-04-21 16:09:49 +03:00
|
|
|
std::size_t mGenerationCounter = 0;
|
2018-04-21 02:57:01 +03:00
|
|
|
boost::optional<TilePosition> mPlayerTile;
|
|
|
|
std::size_t mLastRecastMeshManagerRevision = 0;
|
2018-04-01 03:44:16 +03:00
|
|
|
|
2018-07-14 15:05:28 +03:00
|
|
|
void addChangedTiles(const btCollisionShape& shape, const btTransform& transform, const ChangeType changeType);
|
2018-04-01 20:24:02 +03:00
|
|
|
|
|
|
|
const std::shared_ptr<NavMeshCacheItem>& getCached(const osg::Vec3f& agentHalfExtents) const;
|
2018-03-14 01:49:08 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|