mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-03 17:37:18 +00:00
beeb882ea8
To reduce cache size and make it more flexible. Adding off mesh connections to the navmesh is the last step of navmesh generation and it's very fast comparing to other steps (microseconds vs milliseconds). Having less cache size makes get and set operations almost 2x times faster that also have an order of microseconds. So in total there is no performance impact.
53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
#include "preparednavmeshdata.hpp"
|
|
#include "preparednavmeshdatatuple.hpp"
|
|
|
|
#include <Recast.h>
|
|
#include <RecastAlloc.h>
|
|
|
|
namespace
|
|
{
|
|
using namespace DetourNavigator;
|
|
|
|
void initPolyMeshDetail(rcPolyMeshDetail& value) noexcept
|
|
{
|
|
value.meshes = nullptr;
|
|
value.verts = nullptr;
|
|
value.tris = nullptr;
|
|
value.nmeshes = 0;
|
|
value.nverts = 0;
|
|
value.ntris = 0;
|
|
}
|
|
|
|
void freePolyMeshDetail(rcPolyMeshDetail& value) noexcept
|
|
{
|
|
rcFree(value.meshes);
|
|
rcFree(value.verts);
|
|
rcFree(value.tris);
|
|
}
|
|
}
|
|
|
|
template <class T>
|
|
inline constexpr auto operator==(const T& lhs, const T& rhs) noexcept
|
|
-> std::enable_if_t<std::is_same_v<std::void_t<decltype(makeTuple(lhs))>, void>, bool>
|
|
{
|
|
return makeTuple(lhs) == makeTuple(rhs);
|
|
}
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
PreparedNavMeshData::PreparedNavMeshData() noexcept
|
|
{
|
|
initPolyMeshDetail(mPolyMeshDetail);
|
|
}
|
|
|
|
PreparedNavMeshData::~PreparedNavMeshData() noexcept
|
|
{
|
|
freePolyMeshDetail(mPolyMeshDetail);
|
|
}
|
|
|
|
bool operator==(const PreparedNavMeshData& lhs, const PreparedNavMeshData& rhs) noexcept
|
|
{
|
|
return makeTuple(lhs) == makeTuple(rhs);
|
|
}
|
|
}
|