mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:23:54 +00:00
Check dtNavMeshQuery::findStraightPath status
This commit is contained in:
parent
793c30ab8d
commit
a54c4bc2e9
1 changed files with 6 additions and 3 deletions
|
@ -105,7 +105,7 @@ namespace DetourNavigator
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<SteerTarget> getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos,
|
std::optional<SteerTarget> getSteerTarget(const dtNavMeshQuery& navMeshQuery, const osg::Vec3f& startPos,
|
||||||
const osg::Vec3f& endPos, const float minTargetDist, const std::vector<dtPolyRef>& path)
|
const osg::Vec3f& endPos, const float minTargetDist, const std::vector<dtPolyRef>& path)
|
||||||
{
|
{
|
||||||
// Find steer target.
|
// Find steer target.
|
||||||
|
@ -115,8 +115,11 @@ namespace DetourNavigator
|
||||||
std::array<unsigned char, maxSteerPoints> steerPathFlags;
|
std::array<unsigned char, maxSteerPoints> steerPathFlags;
|
||||||
std::array<dtPolyRef, maxSteerPoints> steerPathPolys;
|
std::array<dtPolyRef, maxSteerPoints> steerPathPolys;
|
||||||
int nsteerPath = 0;
|
int nsteerPath = 0;
|
||||||
navQuery.findStraightPath(startPos.ptr(), endPos.ptr(), path.data(), int(path.size()), steerPath.data(),
|
const dtStatus status = navMeshQuery.findStraightPath(startPos.ptr(), endPos.ptr(), path.data(),
|
||||||
steerPathFlags.data(), steerPathPolys.data(), &nsteerPath, maxSteerPoints);
|
static_cast<int>(path.size()), steerPath.data(), steerPathFlags.data(), steerPathPolys.data(),
|
||||||
|
&nsteerPath, maxSteerPoints);
|
||||||
|
if (dtStatusFailed(status))
|
||||||
|
return std::nullopt;
|
||||||
assert(nsteerPath >= 0);
|
assert(nsteerPath >= 0);
|
||||||
if (!nsteerPath)
|
if (!nsteerPath)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
Loading…
Reference in a new issue