mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Sort water and off mesh connections for recast mesh
Inconsisten order of these objects in navmesh cache key leads to cache misses due to key inequality.
This commit is contained in:
parent
489107c5ee
commit
ad1f8c1e84
5 changed files with 33 additions and 0 deletions
|
@ -68,4 +68,19 @@ inline std::ostream& operator <<(std::ostream& stream, BroadphaseNativeTypes val
|
|||
}
|
||||
}
|
||||
|
||||
inline bool operator <(const btVector3& lhs, const btVector3& rhs)
|
||||
{
|
||||
return std::tie(lhs.x(), lhs.y(), lhs.z()) < std::tie(rhs.x(), rhs.y(), rhs.z());
|
||||
}
|
||||
|
||||
inline bool operator <(const btMatrix3x3& lhs, const btMatrix3x3& rhs)
|
||||
{
|
||||
return std::tie(lhs[0], lhs[1], lhs[2]) < std::tie(rhs[0], rhs[1], rhs[2]);
|
||||
}
|
||||
|
||||
inline bool operator <(const btTransform& lhs, const btTransform& rhs)
|
||||
{
|
||||
return std::tie(lhs.getBasis(), lhs.getOrigin()) < std::tie(rhs.getBasis(), rhs.getOrigin());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
struct OffMeshConnection
|
||||
|
@ -13,6 +15,11 @@ namespace DetourNavigator
|
|||
osg::Vec3f mEnd;
|
||||
AreaType mAreaType;
|
||||
};
|
||||
|
||||
inline bool operator<(const OffMeshConnection& lhs, const OffMeshConnection& rhs)
|
||||
{
|
||||
return std::tie(lhs.mStart, lhs.mEnd, lhs.mAreaType) < std::tie(rhs.mStart, rhs.mEnd, rhs.mAreaType);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace DetourNavigator
|
|||
std::for_each(byId.first, byId.second, [&] (const auto& v) { result.push_back(v.second); });
|
||||
});
|
||||
|
||||
std::sort(result.begin(), result.end());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
#include "chunkytrimesh.hpp"
|
||||
#include "bounds.hpp"
|
||||
|
||||
#include <components/bullethelpers/operators.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
|
@ -87,6 +90,11 @@ namespace DetourNavigator
|
|||
ChunkyTriMesh mChunkyTriMesh;
|
||||
Bounds mBounds;
|
||||
};
|
||||
|
||||
inline bool operator<(const RecastMesh::Water& lhs, const RecastMesh::Water& rhs)
|
||||
{
|
||||
return std::tie(lhs.mCellSize, lhs.mTransform) < std::tie(rhs.mCellSize, rhs.mTransform);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -155,6 +155,7 @@ namespace DetourNavigator
|
|||
std::shared_ptr<RecastMesh> RecastMeshBuilder::create(std::size_t generation, std::size_t revision)
|
||||
{
|
||||
optimizeRecastMesh(mIndices, mVertices);
|
||||
std::sort(mWater.begin(), mWater.end());
|
||||
return std::make_shared<RecastMesh>(generation, revision, mIndices, mVertices, mAreaTypes,
|
||||
mWater, mSettings.get().mTrianglesPerChunk);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue