2018-03-14 01:49:08 +03:00
|
|
|
#include "recastmesh.hpp"
|
2018-07-12 11:44:11 +03:00
|
|
|
#include "exceptions.hpp"
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-04-01 22:17:04 +03:00
|
|
|
#include <Recast.h>
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2021-07-11 21:43:19 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-11-04 02:48:32 +01:00
|
|
|
RecastMesh::RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector<CellWater> water,
|
2021-07-14 20:57:52 +02:00
|
|
|
std::vector<Heightfield> heightfields, std::vector<FlatHeightfield> flatHeightfields)
|
2019-11-27 23:45:01 +01:00
|
|
|
: mGeneration(generation)
|
|
|
|
, mRevision(revision)
|
2021-07-11 21:43:19 +02:00
|
|
|
, mMesh(std::move(mesh))
|
2018-07-20 22:11:34 +03:00
|
|
|
, mWater(std::move(water))
|
2021-07-14 20:57:52 +02:00
|
|
|
, mHeightfields(std::move(heightfields))
|
|
|
|
, mFlatHeightfields(std::move(flatHeightfields))
|
2018-03-14 01:49:08 +03:00
|
|
|
{
|
2021-07-03 17:39:34 +02:00
|
|
|
mWater.shrink_to_fit();
|
2021-07-14 20:57:52 +02:00
|
|
|
mHeightfields.shrink_to_fit();
|
|
|
|
for (Heightfield& v : mHeightfields)
|
|
|
|
v.mHeights.shrink_to_fit();
|
2018-03-14 01:49:08 +03:00
|
|
|
}
|
|
|
|
}
|