2019-02-16 12:27:02 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVIGATORIMPL_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVIGATORIMPL_H
|
|
|
|
|
|
|
|
#include "navigator.hpp"
|
|
|
|
#include "navmeshmanager.hpp"
|
|
|
|
|
2020-06-11 21:23:30 +00:00
|
|
|
#include <set>
|
|
|
|
|
2019-02-16 12:27:02 +00:00
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class NavigatorImpl final : public Navigator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Navigator constructor initializes all internal data. Constructed object is ready to build a scene.
|
|
|
|
* @param settings allows to customize navigator work. Constructor is only place to set navigator settings.
|
|
|
|
*/
|
2020-10-22 21:57:53 +00:00
|
|
|
explicit NavigatorImpl(const Settings& settings);
|
2019-02-16 12:27:02 +00:00
|
|
|
|
|
|
|
void addAgent(const osg::Vec3f& agentHalfExtents) override;
|
|
|
|
|
|
|
|
void removeAgent(const osg::Vec3f& agentHalfExtents) override;
|
|
|
|
|
|
|
|
bool addObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform) override;
|
|
|
|
|
|
|
|
bool addObject(const ObjectId id, const DoorShapes& shapes, const btTransform& transform) override;
|
|
|
|
|
|
|
|
bool updateObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform) override;
|
|
|
|
|
|
|
|
bool updateObject(const ObjectId id, const DoorShapes& shapes, const btTransform& transform) override;
|
|
|
|
|
|
|
|
bool removeObject(const ObjectId id) override;
|
|
|
|
|
2021-11-04 01:48:32 +00:00
|
|
|
bool addWater(const osg::Vec2i& cellPosition, int cellSize, float level) override;
|
2019-02-16 12:27:02 +00:00
|
|
|
|
|
|
|
bool removeWater(const osg::Vec2i& cellPosition) override;
|
|
|
|
|
2021-11-04 02:19:41 +00:00
|
|
|
bool addHeightfield(const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape) override;
|
2021-07-14 18:57:52 +00:00
|
|
|
|
|
|
|
bool removeHeightfield(const osg::Vec2i& cellPosition) override;
|
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void addPathgrid(const ESM::Cell& cell, const ESM::Pathgrid& pathgrid) override;
|
2020-06-11 21:23:30 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void removePathgrid(const ESM::Pathgrid& pathgrid) override;
|
2020-06-11 21:23:30 +00:00
|
|
|
|
2019-02-16 12:27:02 +00:00
|
|
|
void update(const osg::Vec3f& playerPosition) override;
|
|
|
|
|
2021-05-27 14:52:01 +00:00
|
|
|
void updatePlayerPosition(const osg::Vec3f& playerPosition) override;
|
|
|
|
|
2020-05-08 13:37:00 +00:00
|
|
|
void setUpdatesEnabled(bool enabled) override;
|
|
|
|
|
2021-05-14 19:06:29 +00:00
|
|
|
void wait(Loading::Listener& listener, WaitConditionType waitConditionType) override;
|
2019-02-16 12:27:02 +00:00
|
|
|
|
|
|
|
SharedNavMeshCacheItem getNavMesh(const osg::Vec3f& agentHalfExtents) const override;
|
|
|
|
|
|
|
|
std::map<osg::Vec3f, SharedNavMeshCacheItem> getNavMeshes() const override;
|
|
|
|
|
2019-02-19 08:46:00 +00:00
|
|
|
const Settings& getSettings() const override;
|
2019-02-16 12:27:02 +00:00
|
|
|
|
2019-03-17 17:18:53 +00:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats& stats) const override;
|
|
|
|
|
2021-10-09 16:36:37 +00:00
|
|
|
RecastMeshTiles getRecastMeshTiles() const override;
|
2019-11-27 22:45:01 +00:00
|
|
|
|
2021-03-23 22:15:13 +00:00
|
|
|
float getMaxNavmeshAreaRealRadius() const override;
|
|
|
|
|
2019-02-16 12:27:02 +00:00
|
|
|
private:
|
|
|
|
Settings mSettings;
|
|
|
|
NavMeshManager mNavMeshManager;
|
2020-05-08 13:37:00 +00:00
|
|
|
bool mUpdatesEnabled;
|
2021-05-27 14:52:01 +00:00
|
|
|
std::optional<TilePosition> mLastPlayerPosition;
|
2019-02-16 12:27:02 +00:00
|
|
|
std::map<osg::Vec3f, std::size_t> mAgents;
|
|
|
|
std::unordered_map<ObjectId, ObjectId> mAvoidIds;
|
|
|
|
std::unordered_map<ObjectId, ObjectId> mWaterIds;
|
|
|
|
|
|
|
|
void updateAvoidShapeId(const ObjectId id, const ObjectId avoidId);
|
|
|
|
void updateWaterShapeId(const ObjectId id, const ObjectId waterId);
|
|
|
|
void updateId(const ObjectId id, const ObjectId waterId, std::unordered_map<ObjectId, ObjectId>& ids);
|
2019-03-10 11:36:16 +00:00
|
|
|
void removeUnusedNavMeshes();
|
2019-02-16 12:27:02 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|