1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 04:45:36 +00:00
openmw/components/detournavigator/recastmesh.cpp

24 lines
990 B
C++
Raw Normal View History

2018-03-13 22:49:08 +00:00
#include "recastmesh.hpp"
#include "settings.hpp"
2018-07-12 08:44:11 +00:00
#include "exceptions.hpp"
2018-03-13 22:49:08 +00:00
2018-04-01 19:17:04 +00:00
#include <Recast.h>
2018-03-13 22:49:08 +00:00
namespace DetourNavigator
{
2018-07-12 08:44:11 +00:00
RecastMesh::RecastMesh(std::vector<int> indices, std::vector<float> vertices,
2018-07-20 19:11:34 +00:00
std::vector<AreaType> areaTypes, std::vector<Water> water, const Settings& settings)
2018-03-13 22:49:08 +00:00
: mIndices(std::move(indices))
, mVertices(std::move(vertices))
2018-07-18 19:09:50 +00:00
, mAreaTypes(std::move(areaTypes))
2018-07-20 19:11:34 +00:00
, mWater(std::move(water))
2018-07-18 19:09:50 +00:00
, mChunkyTriMesh(mVertices, mIndices, mAreaTypes, settings.mTrianglesPerChunk)
2018-03-13 22:49:08 +00:00
{
2018-07-18 19:09:50 +00:00
if (getTrianglesCount() != mAreaTypes.size())
2018-07-12 08:44:11 +00:00
throw InvalidArgument("number of flags doesn't match number of triangles: triangles="
2018-07-18 19:09:50 +00:00
+ std::to_string(getTrianglesCount()) + ", areaTypes=" + std::to_string(mAreaTypes.size()));
2018-04-15 22:39:51 +00:00
if (getVerticesCount())
rcCalcBounds(mVertices.data(), static_cast<int>(getVerticesCount()), mBoundsMin.ptr(), mBoundsMax.ptr());
2018-03-13 22:49:08 +00:00
}
}