2018-03-13 22:49:08 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
|
|
|
|
|
2018-08-26 20:27:38 +00:00
|
|
|
#include "offmeshconnectionsmanager.hpp"
|
2018-04-15 19:54:45 +00:00
|
|
|
#include "settings.hpp"
|
2018-04-16 19:57:35 +00:00
|
|
|
#include "navmeshcacheitem.hpp"
|
2018-04-01 00:44:16 +00:00
|
|
|
#include "tileposition.hpp"
|
2018-04-15 22:07:18 +00:00
|
|
|
#include "tilebounds.hpp"
|
2018-09-29 17:36:42 +00:00
|
|
|
#include "sharednavmesh.hpp"
|
2018-09-30 22:33:25 +00:00
|
|
|
#include "navmeshtilescache.hpp"
|
2018-04-01 00:44:16 +00:00
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class dtNavMesh;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class RecastMesh;
|
|
|
|
struct Settings;
|
|
|
|
|
2019-03-08 12:06:47 +00:00
|
|
|
enum class UpdateNavMeshStatus : unsigned
|
2018-04-21 12:27:47 +00:00
|
|
|
{
|
2019-03-08 12:06:47 +00:00
|
|
|
ignored = 0,
|
|
|
|
removed = 1 << 0,
|
|
|
|
added = 1 << 1,
|
|
|
|
replaced = removed | added,
|
2019-03-08 12:28:32 +00:00
|
|
|
failed = 1 << 2,
|
|
|
|
lost = removed | failed,
|
2018-04-21 12:27:47 +00:00
|
|
|
};
|
|
|
|
|
2019-03-08 12:28:32 +00:00
|
|
|
inline bool isSuccess(UpdateNavMeshStatus value)
|
|
|
|
{
|
|
|
|
return (static_cast<unsigned>(value) & static_cast<unsigned>(UpdateNavMeshStatus::failed)) == 0;
|
|
|
|
}
|
|
|
|
|
2018-04-20 23:57:01 +00:00
|
|
|
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)));
|
2019-03-08 12:28:32 +00:00
|
|
|
return expectedTilesCount <= maxTiles;
|
2018-04-20 23:57:01 +00:00
|
|
|
}
|
|
|
|
|
2018-04-01 17:24:02 +00:00
|
|
|
NavMeshPtr makeEmptyNavMesh(const Settings& settings);
|
2018-04-01 00:44:16 +00:00
|
|
|
|
2018-04-15 22:07:18 +00:00
|
|
|
UpdateNavMeshStatus updateNavMesh(const osg::Vec3f& agentHalfExtents, const RecastMesh* recastMesh,
|
2018-08-26 20:27:38 +00:00
|
|
|
const TilePosition& changedTile, const TilePosition& playerTile,
|
|
|
|
const std::vector<OffMeshConnection>& offMeshConnections, const Settings& settings,
|
2018-09-30 22:33:25 +00:00
|
|
|
const SharedNavMeshCacheItem& navMeshCacheItem, NavMeshTilesCache& navMeshTilesCache);
|
2018-03-13 22:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|