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-16 19:57:35 +00:00
|
|
|
#include "navmeshcacheitem.hpp"
|
2018-04-01 00:44:16 +00:00
|
|
|
#include "tileposition.hpp"
|
2018-09-29 17:36:42 +00:00
|
|
|
#include "sharednavmesh.hpp"
|
2018-09-30 22:33:25 +00:00
|
|
|
#include "navmeshtilescache.hpp"
|
2021-07-13 22:03:10 +00:00
|
|
|
#include "offmeshconnection.hpp"
|
2021-07-09 20:51:42 +00:00
|
|
|
#include "navmeshdb.hpp"
|
|
|
|
|
|
|
|
#include <components/misc/guarded.hpp>
|
2018-04-01 00:44:16 +00:00
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
|
|
|
#include <memory>
|
2021-07-13 22:03:10 +00:00
|
|
|
#include <vector>
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
class dtNavMesh;
|
2021-06-29 01:49:21 +00:00
|
|
|
struct rcConfig;
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class RecastMesh;
|
|
|
|
struct Settings;
|
2021-07-13 22:03:10 +00:00
|
|
|
struct PreparedNavMeshData;
|
|
|
|
struct NavMeshData;
|
2018-03-13 22:49:08 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-06-29 01:49:21 +00:00
|
|
|
inline bool isEmpty(const RecastMesh& recastMesh)
|
|
|
|
{
|
|
|
|
return recastMesh.getMesh().getIndices().empty()
|
|
|
|
&& recastMesh.getWater().empty()
|
|
|
|
&& recastMesh.getHeightfields().empty()
|
|
|
|
&& recastMesh.getFlatHeightfields().empty();
|
|
|
|
}
|
2021-11-06 12:46:43 +00:00
|
|
|
|
2021-06-29 01:49:21 +00:00
|
|
|
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh,
|
|
|
|
const TilePosition& tilePosition, const osg::Vec3f& agentHalfExtents, const RecastSettings& settings);
|
2021-07-13 22:03:10 +00:00
|
|
|
|
|
|
|
NavMeshData makeNavMeshTileData(const PreparedNavMeshData& data,
|
|
|
|
const std::vector<OffMeshConnection>& offMeshConnections, const osg::Vec3f& agentHalfExtents,
|
2021-11-06 12:46:43 +00:00
|
|
|
const TilePosition& tile, const RecastSettings& settings);
|
2021-07-13 22:03:10 +00:00
|
|
|
|
2018-04-01 17:24:02 +00:00
|
|
|
NavMeshPtr makeEmptyNavMesh(const Settings& settings);
|
2018-03-13 22:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|