1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-31 18:15:01 +00:00
OpenMW/components/detournavigator/gettilespositions.hpp
elsid 69cf507db8
Fix navmesh update on player changing tile
In cases when objects are not present on the scene (e.g. generated exterior
cells) navmesh is not updated because area that suppose to be covered with it
was not updated. It was updated only during cell change. This is a regression
from d15e1dca84.

Set TileCachedRecastMeshManager range on NavMeshManager update to make sure it
always covers correct area around player.

Return a union of objects, heightfields and water ranges from
getLimitedObjectsRange intersected with range provided above.
2024-01-09 01:18:45 +01:00

58 lines
1.9 KiB
C++

#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_GETTILESPOSITIONS_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_GETTILESPOSITIONS_H
#include "tilebounds.hpp"
#include "tileposition.hpp"
#include "tilespositionsrange.hpp"
class btVector3;
class btTransform;
class btCollisionShape;
namespace osg
{
class Vec2f;
}
namespace DetourNavigator
{
struct RecastSettings;
TilesPositionsRange makeTilesPositionsRange(
const osg::Vec2f& aabbMin, const osg::Vec2f& aabbMax, const RecastSettings& settings);
TilesPositionsRange makeTilesPositionsRange(
const btCollisionShape& shape, const btTransform& transform, const RecastSettings& settings);
TilesPositionsRange makeTilesPositionsRange(const btCollisionShape& shape, const btTransform& transform,
const TileBounds& bounds, const RecastSettings& settings);
TilesPositionsRange makeTilesPositionsRange(
const int cellSize, const btVector3& shift, const RecastSettings& settings);
template <class Callback>
inline void getTilesPositions(const TilesPositionsRange& range, Callback&& callback)
{
for (int tileX = range.mBegin.x(); tileX < range.mEnd.x(); ++tileX)
for (int tileY = range.mBegin.y(); tileY < range.mEnd.y(); ++tileY)
callback(TilePosition{ tileX, tileY });
}
inline bool isInTilesPositionsRange(int begin, int end, int coordinate)
{
return begin <= coordinate && coordinate < end;
}
inline bool isInTilesPositionsRange(const TilesPositionsRange& range, const TilePosition& position)
{
return isInTilesPositionsRange(range.mBegin.x(), range.mEnd.x(), position.x())
&& isInTilesPositionsRange(range.mBegin.y(), range.mEnd.y(), position.y());
}
TilesPositionsRange getIntersection(const TilesPositionsRange& a, const TilesPositionsRange& b) noexcept;
TilesPositionsRange getUnion(const TilesPositionsRange& a, const TilesPositionsRange& b) noexcept;
}
#endif