mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
1a12c453d6
Actors may have different collision shapes. Currently there are axis-aligned bounding boxes and rotating bounding boxes. With AABB it's required to use bounding cylinder for navmesh agent to avoid providing paths where actor can't pass. But for rotating bounding boxes cylinder with diameter equal to the front face width should be used to not reduce of available paths. For example rats have rotating bounding box as collision shape because of the difference between front and side faces width. * Add agent bounds to navmesh tile db cache key. This is required to distinguish tiles for agents with different bounds. * Increase navmesh version because navmesh tile db cache key and data has changed. * Move navmesh version to the code to avoid misconfiguration by users. * Fix all places where wrong half extents were used for pathfinding.
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_MAKENAVMESH_H
|
|
|
|
#include "offmeshconnectionsmanager.hpp"
|
|
#include "navmeshcacheitem.hpp"
|
|
#include "tileposition.hpp"
|
|
#include "sharednavmesh.hpp"
|
|
#include "navmeshtilescache.hpp"
|
|
#include "offmeshconnection.hpp"
|
|
#include "navmeshdb.hpp"
|
|
|
|
#include <components/misc/guarded.hpp>
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class dtNavMesh;
|
|
struct rcConfig;
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
class RecastMesh;
|
|
struct Settings;
|
|
struct PreparedNavMeshData;
|
|
struct NavMeshData;
|
|
|
|
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 <= maxTiles;
|
|
}
|
|
|
|
inline bool isEmpty(const RecastMesh& recastMesh)
|
|
{
|
|
return recastMesh.getMesh().getIndices().empty()
|
|
&& recastMesh.getWater().empty()
|
|
&& recastMesh.getHeightfields().empty()
|
|
&& recastMesh.getFlatHeightfields().empty();
|
|
}
|
|
|
|
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh,
|
|
const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings);
|
|
|
|
NavMeshData makeNavMeshTileData(const PreparedNavMeshData& data,
|
|
const std::vector<OffMeshConnection>& offMeshConnections, const AgentBounds& agentBounds,
|
|
const TilePosition& tile, const RecastSettings& settings);
|
|
|
|
NavMeshPtr makeEmptyNavMesh(const Settings& settings);
|
|
}
|
|
|
|
#endif
|