mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#include "navigator.hpp"
|
|
#include "debug.hpp"
|
|
#include "settingsutils.hpp"
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
Navigator::Navigator(const Settings& settings)
|
|
: mSettings(settings)
|
|
, mNavMeshManager(mSettings)
|
|
{
|
|
}
|
|
|
|
void Navigator::addAgent(const osg::Vec3f& agentHalfExtents)
|
|
{
|
|
++mAgents[agentHalfExtents];
|
|
mNavMeshManager.addAgent(agentHalfExtents);
|
|
}
|
|
|
|
void Navigator::removeAgent(const osg::Vec3f& agentHalfExtents)
|
|
{
|
|
const auto it = mAgents.find(agentHalfExtents);
|
|
if (it == mAgents.end() || --it->second)
|
|
return;
|
|
mAgents.erase(it);
|
|
mNavMeshManager.reset(agentHalfExtents);
|
|
}
|
|
|
|
bool Navigator::removeObject(std::size_t id)
|
|
{
|
|
return mNavMeshManager.removeObject(id);
|
|
}
|
|
|
|
void Navigator::update(const osg::Vec3f& playerPosition)
|
|
{
|
|
for (const auto& v : mAgents)
|
|
mNavMeshManager.update(playerPosition, v.first);
|
|
}
|
|
|
|
void Navigator::wait()
|
|
{
|
|
mNavMeshManager.wait();
|
|
}
|
|
}
|