1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00
elsid af7059373c
Make RecastMesh independent from the order of RecastMeshBuilder calls
To make sure RecastMesh objects are equal if built with the same data but in
different order. Will be used later when there will be more than one place
building RecasMesh objects.
2021-07-26 00:22:20 +02:00

33 lines
1.2 KiB
C++

#include "recastmesh.hpp"
#include "exceptions.hpp"
#include <Recast.h>
namespace DetourNavigator
{
Mesh::Mesh(std::vector<int>&& indices, std::vector<float>&& vertices, std::vector<AreaType>&& areaTypes)
{
if (indices.size() / 3 != areaTypes.size())
throw InvalidArgument("Number of flags doesn't match number of triangles: triangles="
+ std::to_string(indices.size() / 3) + ", areaTypes=" + std::to_string(areaTypes.size()));
indices.shrink_to_fit();
vertices.shrink_to_fit();
areaTypes.shrink_to_fit();
mIndices = std::move(indices);
mVertices = std::move(vertices);
mAreaTypes = std::move(areaTypes);
}
RecastMesh::RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector<Water> water)
: mGeneration(generation)
, mRevision(revision)
, mMesh(std::move(mesh))
, mWater(std::move(water))
{
if (mMesh.getVerticesCount() > 0)
rcCalcBounds(mMesh.getVertices().data(), static_cast<int>(mMesh.getVerticesCount()),
mBounds.mMin.ptr(), mBounds.mMax.ptr());
mWater.shrink_to_fit();
}
}