1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/components/detournavigator/makenavmesh.hpp

55 lines
1.4 KiB
C++
Raw Normal View History

2018-03-13 22:49:08 +00:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
#include "settings.hpp"
#include "navmeshcacheitem.hpp"
#include "tileposition.hpp"
2018-04-15 22:07:18 +00:00
#include "tilebounds.hpp"
2018-03-13 22:49:08 +00:00
#include <osg/Vec3f>
#include <memory>
class dtNavMesh;
namespace DetourNavigator
{
class RecastMesh;
class SharedNavMesh;
2018-03-13 22:49:08 +00:00
struct Settings;
using NavMeshPtr = std::shared_ptr<dtNavMesh>;
2018-04-21 12:27:47 +00:00
enum class UpdateNavMeshStatus
{
ignore,
removed,
add,
replaced
};
inline float getLength(const osg::Vec2i& value)
{
return std::sqrt(float(osg::square(value.x()) + osg::square(value.y())));
}
inline float getDistance(const TilePosition& lhs, const TilePosition& rhs)
{
return getLength(lhs - rhs);
}
inline bool shouldAddTile(const TilePosition& changedTile, const TilePosition& playerTile, int maxTiles)
{
const auto expectedTilesCount = std::ceil(osg::PI * osg::square(getDistance(changedTile, playerTile)));
return expectedTilesCount * 3 <= maxTiles;
}
NavMeshPtr makeEmptyNavMesh(const Settings& settings);
2018-04-15 22:07:18 +00:00
UpdateNavMeshStatus updateNavMesh(const osg::Vec3f& agentHalfExtents, const RecastMesh* recastMesh,
const TilePosition& changedTile, const TilePosition& playerTile, const Settings& settings,
NavMeshCacheItem& navMeshCacheItem);
2018-03-13 22:49:08 +00:00
}
#endif