forked from mirror/openmw-tes3mp
fix zero div in getXAngleToDir
This commit is contained in:
parent
612c7f1a2f
commit
0775ed75ea
1 changed files with 3 additions and 2 deletions
|
@ -89,7 +89,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
float getXAngleToDir(const osg::Vec3f& dir)
|
float getXAngleToDir(const osg::Vec3f& dir)
|
||||||
{
|
{
|
||||||
return -std::asin(dir.z() / dir.length());
|
float dirLen = dir.length();
|
||||||
|
return (dirLen != 0) ? -std::asin(dir.z() / dirLen) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getZAngleToPoint(const ESM::Pathgrid::Point &origin, const ESM::Pathgrid::Point &dest)
|
float getZAngleToPoint(const ESM::Pathgrid::Point &origin, const ESM::Pathgrid::Point &dest)
|
||||||
|
@ -276,7 +277,7 @@ namespace MWMechanics
|
||||||
const ESM::Pathgrid::Point &nextPoint = *mPath.begin();
|
const ESM::Pathgrid::Point &nextPoint = *mPath.begin();
|
||||||
osg::Vec3f dir = MakeOsgVec3(nextPoint) - osg::Vec3f(x,y,z);
|
osg::Vec3f dir = MakeOsgVec3(nextPoint) - osg::Vec3f(x,y,z);
|
||||||
|
|
||||||
return -std::asin(dir.z() / dir.length());
|
return getXAngleToDir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathFinder::checkPathCompleted(float x, float y, float tolerance)
|
bool PathFinder::checkPathCompleted(float x, float y, float tolerance)
|
||||||
|
|
Loading…
Reference in a new issue