mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
7 years ago
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVIGATOR_H
|
||
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVIGATOR_H
|
||
|
|
||
|
#include "findsmoothpath.hpp"
|
||
|
#include "navmeshmanager.hpp"
|
||
|
#include "settings.hpp"
|
||
|
#include "settingsutils.hpp"
|
||
|
|
||
|
namespace DetourNavigator
|
||
|
{
|
||
|
class Navigator
|
||
|
{
|
||
|
public:
|
||
|
Navigator(const Settings& settings);
|
||
|
|
||
|
void addAgent(const osg::Vec3f& agentHalfExtents);
|
||
|
|
||
|
void removeAgent(const osg::Vec3f& agentHalfExtents);
|
||
|
|
||
|
template <class T>
|
||
|
bool addObject(std::size_t id, const T& shape, const btTransform& transform)
|
||
|
{
|
||
|
return mNavMeshManager.addObject(id, shape, transform);
|
||
|
}
|
||
|
|
||
|
bool removeObject(std::size_t id);
|
||
|
|
||
|
void update();
|
||
|
|
||
|
void wait();
|
||
|
|
||
|
template <class OutputIterator>
|
||
|
OutputIterator findPath(const osg::Vec3f& agentHalfExtents, const osg::Vec3f& start,
|
||
|
const osg::Vec3f& end, OutputIterator out) const
|
||
|
{
|
||
|
const auto navMesh = mNavMeshManager.getNavMesh(agentHalfExtents);
|
||
|
if (!navMesh)
|
||
|
return out;
|
||
|
return findSmoothPath(*navMesh, toNavMeshCoordinates(mSettings, agentHalfExtents),
|
||
|
toNavMeshCoordinates(mSettings, start), toNavMeshCoordinates(mSettings, end), mSettings, out);
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
Settings mSettings;
|
||
|
NavMeshManager mNavMeshManager;
|
||
|
std::map<osg::Vec3f, std::size_t> mAgents;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif
|