Store recast mesh bounds

pull/1633/head
elsid 7 years ago
parent d1d034a1ec
commit f8909218ee
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -252,10 +252,8 @@ namespace DetourNavigator
getRadius(settings, agentHalfExtents),
" changedTile=", changedTile);
osg::Vec3f boundsMin;
osg::Vec3f boundsMax;
rcCalcBounds(recastMesh.getVertices().data(), int(recastMesh.getVerticesCount()),
boundsMin.ptr(), boundsMax.ptr());
const auto& boundsMin = recastMesh.getBoundsMin();
const auto& boundsMax = recastMesh.getBoundsMax();
const auto& params = *navMesh.lock()->getParams();
const osg::Vec3f origin(params.orig[0], params.orig[1], params.orig[2]);

@ -1,7 +1,8 @@
#include "recastmesh.hpp"
#include "chunkytrimesh.hpp"
#include "settings.hpp"
#include <Recast.h>
namespace DetourNavigator
{
RecastMesh::RecastMesh(std::vector<int> indices, std::vector<float> vertices, const Settings& settings)
@ -9,5 +10,6 @@ namespace DetourNavigator
, mVertices(std::move(vertices))
, mChunkyTriMesh(mVertices, mIndices, settings.mTrianglesPerChunk)
{
rcCalcBounds(mVertices.data(), static_cast<int>(getVerticesCount()), mBoundsMin.ptr(), mBoundsMax.ptr());
}
}

@ -6,6 +6,8 @@
#include <memory>
#include <vector>
#include <osg/Vec3f>
namespace DetourNavigator
{
struct Settings;
@ -40,10 +42,22 @@ namespace DetourNavigator
return mChunkyTriMesh;
}
const osg::Vec3f& getBoundsMin() const
{
return mBoundsMin;
}
const osg::Vec3f& getBoundsMax() const
{
return mBoundsMax;
}
private:
std::vector<int> mIndices;
std::vector<float> mVertices;
ChunkyTriMesh mChunkyTriMesh;
osg::Vec3f mBoundsMin;
osg::Vec3f mBoundsMax;
};
}

Loading…
Cancel
Save