mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-07 11:14:08 +03:00
Merge pull request #2023 from elsid/navmesh_cache_limit
Navmesh cache limit
This commit is contained in:
commit
a8d944e756
3 changed files with 21 additions and 15 deletions
|
@ -88,7 +88,7 @@ namespace DetourNavigator
|
|||
return Value();
|
||||
|
||||
const auto navMeshKey = makeNavMeshKey(recastMesh, offMeshConnections);
|
||||
const auto itemSize = navMeshSize + navMeshKey.size();
|
||||
const auto itemSize = navMeshSize + 2 * navMeshKey.size();
|
||||
|
||||
if (itemSize > mFreeNavMeshDataSize + (mMaxNavMeshDataSize - mUsedNavMeshDataSize))
|
||||
return Value();
|
||||
|
@ -131,7 +131,8 @@ namespace DetourNavigator
|
|||
if (value == tileValues->second.Map.end())
|
||||
return;
|
||||
|
||||
mUsedNavMeshDataSize -= static_cast<std::size_t>(item.mNavMeshData.mSize) + item.mNavMeshKey.size();
|
||||
mUsedNavMeshDataSize -= getSize(item);
|
||||
mFreeNavMeshDataSize -= getSize(item);
|
||||
mFreeItems.pop_back();
|
||||
|
||||
tileValues->second.Map.erase(value);
|
||||
|
@ -151,7 +152,7 @@ namespace DetourNavigator
|
|||
return;
|
||||
|
||||
mBusyItems.splice(mBusyItems.end(), mFreeItems, iterator);
|
||||
mFreeNavMeshDataSize -= static_cast<std::size_t>(iterator->mNavMeshData.mSize) + iterator->mNavMeshKey.size();
|
||||
mFreeNavMeshDataSize -= getSize(*iterator);
|
||||
}
|
||||
|
||||
void NavMeshTilesCache::releaseItem(ItemIterator iterator)
|
||||
|
@ -162,6 +163,6 @@ namespace DetourNavigator
|
|||
const std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
mFreeItems.splice(mFreeItems.begin(), mBusyItems, iterator);
|
||||
mFreeNavMeshDataSize += static_cast<std::size_t>(iterator->mNavMeshData.mSize) + iterator->mNavMeshKey.size();
|
||||
mFreeNavMeshDataSize += getSize(*iterator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,11 @@ namespace DetourNavigator
|
|||
void acquireItemUnsafe(ItemIterator iterator);
|
||||
|
||||
void releaseItem(ItemIterator iterator);
|
||||
|
||||
static std::size_t getSize(const Item& item)
|
||||
{
|
||||
return static_cast<std::size_t>(item.mNavMeshData.mSize) + 2 * item.mNavMeshKey.size();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue