forked from teamnwah/openmw-tes3coop
Use Ogre's asin/acos functions which will protect against NaNs
This commit is contained in:
parent
48a08c4c4d
commit
90b55c8d4b
2 changed files with 7 additions and 7 deletions
|
@ -12,13 +12,13 @@
|
|||
#include "creaturestats.hpp"
|
||||
#include "npcstats.hpp"
|
||||
|
||||
#include "OgreMath.h"
|
||||
#include <OgreMath.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
static float sgn(float a)
|
||||
static float sgn(Ogre::Radian a)
|
||||
{
|
||||
if(a > 0)
|
||||
if(a.valueDegrees() > 0)
|
||||
return 1.0;
|
||||
return -1.0;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace MWMechanics
|
|||
float directionY = dest.mY - start.mY;
|
||||
float directionResult = sqrt(directionX * directionX + directionY * directionY);
|
||||
|
||||
zAngle = Ogre::Radian( acos(directionY / directionResult) * sgn(asin(directionX / directionResult)) ).valueDegrees();
|
||||
zAngle = Ogre::Radian( Ogre::Math::ACos(directionY / directionResult) * sgn(Ogre::Math::ASin(directionX / directionResult)) ).valueDegrees();
|
||||
// TODO: use movement settings instead of rotating directly
|
||||
MWBase::Environment::get().getWorld()->rotateObject(actor, 0, 0, zAngle, false);
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ namespace
|
|||
return sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
static float sgn(float a)
|
||||
static float sgn(Ogre::Radian a)
|
||||
{
|
||||
if(a > 0)
|
||||
if(a.valueRadians() > 0)
|
||||
return 1.0;
|
||||
return -1.0;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ namespace MWMechanics
|
|||
float directionY = nextPoint.mY - y;
|
||||
float directionResult = sqrt(directionX * directionX + directionY * directionY);
|
||||
|
||||
return Ogre::Radian(acos(directionY / directionResult) * sgn(asin(directionX / directionResult))).valueDegrees();
|
||||
return Ogre::Radian(Ogre::Math::ACos(directionY / directionResult) * sgn(Ogre::Math::ASin(directionX / directionResult))).valueDegrees();
|
||||
}
|
||||
|
||||
bool PathFinder::checkWaypoint(float x, float y, float z)
|
||||
|
|
Loading…
Reference in a new issue