1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-01-05 22:43:08 +00:00

Use tile coordinates from TileCachedRecastMeshManager to schedule tile generation by navmeshtool

Using a 2D range may consume a lot of memory if there is an object far
from the rest.
This commit is contained in:
elsid 2025-12-27 15:37:55 +01:00
parent e9468267fc
commit 1763928548
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
3 changed files with 7 additions and 4 deletions

View file

@ -260,10 +260,7 @@ namespace NavMeshTool
if (removeUnusedTiles)
navMeshTileConsumer->removeTilesOutsideRange(data.mWorldspace, range);
std::vector<TilePosition> worldspaceTiles;
DetourNavigator::getTilesPositions(
range, [&](const TilePosition& tilePosition) { worldspaceTiles.push_back(tilePosition); });
std::vector<TilePosition> worldspaceTiles = data.mTiles;
{
const std::size_t tiles = worldspaceTiles.size();

View file

@ -33,6 +33,7 @@
#include <algorithm>
#include <memory>
#include <ranges>
#include <sstream>
#include <stdexcept>
#include <string>
@ -371,6 +372,10 @@ namespace NavMeshTool
<< (data.mObjects.size() - cellObjectsBegin) << " objects";
}
const std::map<osg::Vec2i, DetourNavigator::ChangeType> changedTiles = manager.takeChangedTiles(guard.get());
data.mTiles.reserve(changedTiles.size());
std::ranges::transform(changedTiles, std::back_inserter(data.mTiles), [](const auto& v) { return v.first; });
Log(Debug::Info) << "Processed " << cells.size() << " cells, added " << data.mObjects.size() << " objects and "
<< data.mHeightfields.size() << " height fields";

View file

@ -77,6 +77,7 @@ namespace NavMeshTool
std::unique_ptr<TileCachedRecastMeshManager> mTileCachedRecastMeshManager;
btAABB mAabb;
bool mAabbInitialized = false;
std::vector<DetourNavigator::TilePosition> mTiles;
std::vector<BulletObject> mObjects;
std::vector<std::unique_ptr<ESM::Land::LandData>> mLandData;
std::vector<std::vector<float>> mHeightfields;