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:
parent
902b0f9f84
commit
bfcc430822
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user