1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-29 18:32:36 +00:00

Use single map to store processing tiles

This commit is contained in:
elsid 2021-08-06 19:18:46 +02:00
parent 902b0f9f84
commit bfcc430822
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40
2 changed files with 5 additions and 29 deletions

View File

@ -445,23 +445,13 @@ namespace DetourNavigator
return std::this_thread::get_id();
auto locked = mProcessingTiles.lock();
auto agent = locked->find(agentHalfExtents);
if (agent == locked->end())
const auto tile = locked->find(std::make_tuple(agentHalfExtents, changedTile));
if (tile == locked->end())
{
const auto threadId = std::this_thread::get_id();
locked->emplace(agentHalfExtents, std::map<TilePosition, std::thread::id>({{changedTile, threadId}}));
locked->emplace(std::tie(agentHalfExtents, changedTile), threadId);
return threadId;
}
auto tile = agent->second.find(changedTile);
if (tile == agent->second.end())
{
const auto threadId = std::this_thread::get_id();
agent->second.emplace(changedTile, threadId);
return threadId;
}
return tile->second;
}
@ -469,22 +459,8 @@ namespace DetourNavigator
{
if (mSettings.get().mAsyncNavMeshUpdaterThreads <= 1)
return;
auto locked = mProcessingTiles.lock();
auto agent = locked->find(agentHalfExtents);
if (agent == locked->end())
return;
auto tile = agent->second.find(changedTile);
if (tile == agent->second.end())
return;
agent->second.erase(tile);
if (agent->second.empty())
locked->erase(agent);
locked->erase(std::tie(agentHalfExtents, changedTile));
if (locked->empty())
mProcessed.notify_all();
}

View File

@ -95,7 +95,7 @@ namespace DetourNavigator
std::map<osg::Vec3f, std::set<TilePosition>> mPushed;
Misc::ScopeGuarded<TilePosition> mPlayerTile;
NavMeshTilesCache mNavMeshTilesCache;
Misc::ScopeGuarded<std::map<osg::Vec3f, std::map<TilePosition, std::thread::id>>> mProcessingTiles;
Misc::ScopeGuarded<std::map<std::tuple<osg::Vec3f, TilePosition>, std::thread::id>> mProcessingTiles;
std::map<osg::Vec3f, std::map<TilePosition, std::chrono::steady_clock::time_point>> mLastUpdates;
std::set<std::tuple<osg::Vec3f, TilePosition>> mPresentTiles;
std::map<std::thread::id, std::deque<JobIt>> mThreadsQueues;