mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-22 10:39:40 +00:00
Store recast mesh bounds
This commit is contained in:
parent
d1d034a1ec
commit
f8909218ee
3 changed files with 19 additions and 5 deletions
|
@ -252,10 +252,8 @@ namespace DetourNavigator
|
||||||
getRadius(settings, agentHalfExtents),
|
getRadius(settings, agentHalfExtents),
|
||||||
" changedTile=", changedTile);
|
" changedTile=", changedTile);
|
||||||
|
|
||||||
osg::Vec3f boundsMin;
|
const auto& boundsMin = recastMesh.getBoundsMin();
|
||||||
osg::Vec3f boundsMax;
|
const auto& boundsMax = recastMesh.getBoundsMax();
|
||||||
rcCalcBounds(recastMesh.getVertices().data(), int(recastMesh.getVerticesCount()),
|
|
||||||
boundsMin.ptr(), boundsMax.ptr());
|
|
||||||
|
|
||||||
const auto& params = *navMesh.lock()->getParams();
|
const auto& params = *navMesh.lock()->getParams();
|
||||||
const osg::Vec3f origin(params.orig[0], params.orig[1], params.orig[2]);
|
const osg::Vec3f origin(params.orig[0], params.orig[1], params.orig[2]);
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "recastmesh.hpp"
|
#include "recastmesh.hpp"
|
||||||
#include "chunkytrimesh.hpp"
|
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
|
#include <Recast.h>
|
||||||
|
|
||||||
namespace DetourNavigator
|
namespace DetourNavigator
|
||||||
{
|
{
|
||||||
RecastMesh::RecastMesh(std::vector<int> indices, std::vector<float> vertices, const Settings& settings)
|
RecastMesh::RecastMesh(std::vector<int> indices, std::vector<float> vertices, const Settings& settings)
|
||||||
|
@ -9,5 +10,6 @@ namespace DetourNavigator
|
||||||
, mVertices(std::move(vertices))
|
, mVertices(std::move(vertices))
|
||||||
, mChunkyTriMesh(mVertices, mIndices, settings.mTrianglesPerChunk)
|
, mChunkyTriMesh(mVertices, mIndices, settings.mTrianglesPerChunk)
|
||||||
{
|
{
|
||||||
|
rcCalcBounds(mVertices.data(), static_cast<int>(getVerticesCount()), mBoundsMin.ptr(), mBoundsMax.ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <osg/Vec3f>
|
||||||
|
|
||||||
namespace DetourNavigator
|
namespace DetourNavigator
|
||||||
{
|
{
|
||||||
struct Settings;
|
struct Settings;
|
||||||
|
@ -40,10 +42,22 @@ namespace DetourNavigator
|
||||||
return mChunkyTriMesh;
|
return mChunkyTriMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const osg::Vec3f& getBoundsMin() const
|
||||||
|
{
|
||||||
|
return mBoundsMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
const osg::Vec3f& getBoundsMax() const
|
||||||
|
{
|
||||||
|
return mBoundsMax;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> mIndices;
|
std::vector<int> mIndices;
|
||||||
std::vector<float> mVertices;
|
std::vector<float> mVertices;
|
||||||
ChunkyTriMesh mChunkyTriMesh;
|
ChunkyTriMesh mChunkyTriMesh;
|
||||||
|
osg::Vec3f mBoundsMin;
|
||||||
|
osg::Vec3f mBoundsMax;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue