2018-03-13 22:49:08 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
|
|
|
|
|
2022-08-11 22:09:49 +00:00
|
|
|
#include "recastmesh.hpp"
|
2018-04-01 00:44:16 +00:00
|
|
|
#include "tileposition.hpp"
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
{
|
|
|
|
struct Settings;
|
2021-07-13 22:03:10 +00:00
|
|
|
struct PreparedNavMeshData;
|
|
|
|
struct NavMeshData;
|
2022-08-11 22:09:49 +00:00
|
|
|
struct OffMeshConnection;
|
|
|
|
struct AgentBounds;
|
|
|
|
struct RecastSettings;
|
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,
|
2022-06-16 22:28:44 +00:00
|
|
|
const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings);
|
2021-07-13 22:03:10 +00:00
|
|
|
|
|
|
|
NavMeshData makeNavMeshTileData(const PreparedNavMeshData& data,
|
2022-06-16 22:28:44 +00:00
|
|
|
const std::vector<OffMeshConnection>& offMeshConnections, const AgentBounds& agentBounds,
|
2021-11-06 12:46:43 +00:00
|
|
|
const TilePosition& tile, const RecastSettings& settings);
|
2021-07-13 22:03:10 +00:00
|
|
|
|
2023-02-17 13:55:05 +00:00
|
|
|
void initEmptyNavMesh(const Settings& settings, dtNavMesh& navMesh);
|
2023-01-17 22:31:17 +00:00
|
|
|
|
|
|
|
bool isSupportedAgentBounds(const RecastSettings& settings, const AgentBounds& agentBounds);
|
2018-03-13 22:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|