mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 21:09:45 +00:00
Use single set to store pushed tiles
This commit is contained in:
parent
a97b2ced27
commit
8bca9eec80
2 changed files with 8 additions and 15 deletions
|
@ -29,13 +29,12 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
int getMinDistanceTo(const TilePosition& position, int maxDistance,
|
int getMinDistanceTo(const TilePosition& position, int maxDistance,
|
||||||
const std::map<osg::Vec3f, std::set<TilePosition>>& tilesPerHalfExtents,
|
const std::set<std::tuple<osg::Vec3f, TilePosition>>& pushedTiles,
|
||||||
const std::set<std::tuple<osg::Vec3f, TilePosition>>& presentTiles)
|
const std::set<std::tuple<osg::Vec3f, TilePosition>>& presentTiles)
|
||||||
{
|
{
|
||||||
int result = maxDistance;
|
int result = maxDistance;
|
||||||
for (const auto& [halfExtents, tiles] : tilesPerHalfExtents)
|
for (const auto& [halfExtents, tile] : pushedTiles)
|
||||||
for (const TilePosition& tile : tiles)
|
if (presentTiles.find(std::tie(halfExtents, tile)) == presentTiles.end())
|
||||||
if (presentTiles.find(std::make_tuple(halfExtents, tile)) == presentTiles.end())
|
|
||||||
result = std::min(result, getManhattanDistance(position, tile));
|
result = std::min(result, getManhattanDistance(position, tile));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +119,7 @@ namespace DetourNavigator
|
||||||
|
|
||||||
for (const auto& changedTile : changedTiles)
|
for (const auto& changedTile : changedTiles)
|
||||||
{
|
{
|
||||||
if (mPushed[agentHalfExtents].insert(changedTile.first).second)
|
if (mPushed.emplace(agentHalfExtents, changedTile.first).second)
|
||||||
{
|
{
|
||||||
Job job;
|
Job job;
|
||||||
|
|
||||||
|
@ -367,13 +366,7 @@ namespace DetourNavigator
|
||||||
|
|
||||||
if (owner == threadId)
|
if (owner == threadId)
|
||||||
{
|
{
|
||||||
const auto it = mPushed.find(job->mAgentHalfExtents);
|
mPushed.erase(getAgentAndTile(*job));
|
||||||
if (it != mPushed.end())
|
|
||||||
{
|
|
||||||
it->second.erase(job->mChangedTile);
|
|
||||||
if (it->second.empty())
|
|
||||||
mPushed.erase(it);
|
|
||||||
}
|
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +420,7 @@ namespace DetourNavigator
|
||||||
|
|
||||||
const std::lock_guard<std::mutex> lock(mMutex);
|
const std::lock_guard<std::mutex> lock(mMutex);
|
||||||
|
|
||||||
if (mPushed[job->mAgentHalfExtents].insert(job->mChangedTile).second)
|
if (mPushed.emplace(job->mAgentHalfExtents, job->mChangedTile).second)
|
||||||
{
|
{
|
||||||
++job->mTryNumber;
|
++job->mTryNumber;
|
||||||
mWaiting.push_back(job);
|
mWaiting.push_back(job);
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace DetourNavigator
|
||||||
std::condition_variable mProcessed;
|
std::condition_variable mProcessed;
|
||||||
std::list<Job> mJobs;
|
std::list<Job> mJobs;
|
||||||
std::deque<JobIt> mWaiting;
|
std::deque<JobIt> mWaiting;
|
||||||
std::map<osg::Vec3f, std::set<TilePosition>> mPushed;
|
std::set<std::tuple<osg::Vec3f, TilePosition>> mPushed;
|
||||||
Misc::ScopeGuarded<TilePosition> mPlayerTile;
|
Misc::ScopeGuarded<TilePosition> mPlayerTile;
|
||||||
NavMeshTilesCache mNavMeshTilesCache;
|
NavMeshTilesCache mNavMeshTilesCache;
|
||||||
Misc::ScopeGuarded<std::map<std::tuple<osg::Vec3f, TilePosition>, std::thread::id>> mProcessingTiles;
|
Misc::ScopeGuarded<std::map<std::tuple<osg::Vec3f, TilePosition>, std::thread::id>> mProcessingTiles;
|
||||||
|
|
Loading…
Reference in a new issue