mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 03:54:40 +00:00
b0ef20c303
If object is too big iteration over all tiles covering it can take too much time. Limit bounds to a square around a player position to cover only tiles that will be present in navmesh based on max tiles number option.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_GETTILESPOSITIONS_H
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_GETTILESPOSITIONS_H
|
|
|
|
#include "tilebounds.hpp"
|
|
#include "tileposition.hpp"
|
|
|
|
class btVector3;
|
|
class btTransform;
|
|
class btCollisionShape;
|
|
|
|
namespace osg
|
|
{
|
|
class Vec3f;
|
|
}
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
struct RecastSettings;
|
|
|
|
struct TilesPositionsRange
|
|
{
|
|
TilePosition mMin;
|
|
TilePosition mMax;
|
|
};
|
|
|
|
TilesPositionsRange makeTilesPositionsRange(const osg::Vec3f& aabbMin,
|
|
const osg::Vec3f& aabbMax, 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>
|
|
void getTilesPositions(const TilesPositionsRange& range, Callback&& callback)
|
|
{
|
|
for (int tileX = range.mMin.x(); tileX <= range.mMax.x(); ++tileX)
|
|
for (int tileY = range.mMin.y(); tileY <= range.mMax.y(); ++tileY)
|
|
callback(TilePosition {tileX, tileY});
|
|
}
|
|
}
|
|
|
|
#endif
|