|
|
|
@ -42,18 +42,6 @@ namespace
|
|
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
|
{
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
TileBounds makeBounds(const RecastSettings& settings, const osg::Vec2f& center, int maxTiles)
|
|
|
|
|
{
|
|
|
|
|
const float radius = fromNavMeshCoordinates(settings, std::ceil(std::sqrt(static_cast<float>(maxTiles) / osg::PIf) + 1) * getTileSize(settings));
|
|
|
|
|
TileBounds result;
|
|
|
|
|
result.mMin = center - osg::Vec2f(radius, radius);
|
|
|
|
|
result.mMax = center + osg::Vec2f(radius, radius);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NavMeshManager::NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db)
|
|
|
|
|
: mSettings(settings)
|
|
|
|
|
, mRecastMeshManager(settings.mRecast)
|
|
|
|
@ -217,7 +205,6 @@ namespace DetourNavigator
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const auto maxTiles = std::min(mSettings.mMaxTilesNumber, navMesh.getParams()->maxTiles);
|
|
|
|
|
mRecastMeshManager.setBounds(makeBounds(mSettings.mRecast, osg::Vec2f(playerPosition.x(), playerPosition.y()), maxTiles));
|
|
|
|
|
mRecastMeshManager.forEachTile([&] (const TilePosition& tile, CachedRecastMeshManager& recastMeshManager)
|
|
|
|
|
{
|
|
|
|
|
if (tilesToPost.count(tile))
|
|
|
|
@ -276,7 +263,7 @@ namespace DetourNavigator
|
|
|
|
|
void NavMeshManager::addChangedTiles(const btCollisionShape& shape, const btTransform& transform,
|
|
|
|
|
const ChangeType changeType)
|
|
|
|
|
{
|
|
|
|
|
getTilesPositions(makeTilesPositionsRange(shape, transform, mRecastMeshManager.getBounds(), mSettings.mRecast),
|
|
|
|
|
getTilesPositions(makeTilesPositionsRange(shape, transform, mSettings.mRecast),
|
|
|
|
|
[&] (const TilePosition& v) { addChangedTile(v, changeType); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|