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