mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:49:55 +00:00
Replace unordered_map by map for storing objects
For small amount of items it gives better performance for find by key for update.
This commit is contained in:
parent
22c2f106b7
commit
ed91cf9397
2 changed files with 5 additions and 7 deletions
|
@ -12,13 +12,12 @@ namespace DetourNavigator
|
|||
bool RecastMeshManager::addObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform,
|
||||
const AreaType areaType)
|
||||
{
|
||||
const auto object = mObjects.lower_bound(id);
|
||||
if (object != mObjects.end() && object->first == id)
|
||||
return false;
|
||||
const auto iterator = mObjectsOrder.emplace(mObjectsOrder.end(),
|
||||
OscillatingRecastMeshObject(RecastMeshObject(shape, transform, areaType), mRevision + 1));
|
||||
if (!mObjects.emplace(id, iterator).second)
|
||||
{
|
||||
mObjectsOrder.erase(iterator);
|
||||
return false;
|
||||
}
|
||||
mObjects.emplace_hint(object, id, iterator);
|
||||
++mRevision;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <list>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
class btCollisionShape;
|
||||
|
||||
|
@ -67,7 +66,7 @@ namespace DetourNavigator
|
|||
RecastMeshBuilder mMeshBuilder;
|
||||
TileBounds mTileBounds;
|
||||
std::list<OscillatingRecastMeshObject> mObjectsOrder;
|
||||
std::unordered_map<ObjectId, std::list<OscillatingRecastMeshObject>::iterator> mObjects;
|
||||
std::map<ObjectId, std::list<OscillatingRecastMeshObject>::iterator> mObjects;
|
||||
std::list<Water> mWaterOrder;
|
||||
std::map<osg::Vec2i, std::list<Water>::iterator> mWater;
|
||||
std::optional<Report> mLastNavMeshReportedChange;
|
||||
|
|
Loading…
Reference in a new issue