1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-03 18:15:35 +00:00

Got rid of some radians to degrees to radians conversions.

This commit is contained in:
dteviot 2015-07-19 18:01:25 +12:00
parent 3ebe9fb34f
commit 1ed6e95c07
5 changed files with 10 additions and 10 deletions

View file

@ -36,13 +36,13 @@ namespace
float getZAngleToDir(const osg::Vec3f& dir)
{
return osg::RadiansToDegrees(std::atan2(dir.x(), dir.y()));
return std::atan2(dir.x(), dir.y());
}
float getXAngleToDir(const osg::Vec3f& dir, float dirLen = 0.0f)
{
float len = (dirLen > 0.0f)? dirLen : dir.length();
return osg::RadiansToDegrees(-std::asin(dir.z() / len));
return -std::asin(dir.z() / len);
}
@ -221,12 +221,12 @@ namespace MWMechanics
if(movement.mRotation[2] != 0)
{
if(zTurn(actor, osg::DegreesToRadians(movement.mRotation[2]))) movement.mRotation[2] = 0;
if(zTurn(actor, movement.mRotation[2])) movement.mRotation[2] = 0;
}
if(movement.mRotation[0] != 0)
{
if(smoothTurn(actor, osg::DegreesToRadians(movement.mRotation[0]), 0)) movement.mRotation[0] = 0;
if(smoothTurn(actor, movement.mRotation[0], 0)) movement.mRotation[0] = 0;
}
bool& attack = storage.mAttack;

View file

@ -104,7 +104,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
actor.getClass().getMovementSettings(actor).mPosition[0] = 1;
actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
// change the angle a bit, too
zTurn(actor, osg::DegreesToRadians(mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1])));
zTurn(actor, mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1]));
}
}
else { //Not stuck, so reset things
@ -117,7 +117,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
actor.getClass().getMovementSettings(actor).mPosition[1] = 1; //Just run forward the rest of the time
}
zTurn(actor, osg::DegreesToRadians(mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1])));
zTurn(actor, mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]));
return false;
}

View file

@ -234,7 +234,7 @@ namespace MWMechanics
if(walking) // have not yet reached the destination
{
// turn towards the next point in mPath
zTurn(actor, osg::DegreesToRadians(storage.mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1])));
zTurn(actor, storage.mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]));
actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
evadeObstacles(actor, storage, duration);
@ -397,7 +397,7 @@ namespace MWMechanics
actor.getClass().getMovementSettings(actor).mPosition[1] = 0.1f;
// change the angle a bit, too
const ESM::Position& pos = actor.getRefData().getPosition();
zTurn(actor, osg::DegreesToRadians(storage.mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1])));
zTurn(actor, storage.mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1]));
}
mStuckCount++; // TODO: maybe no longer needed
}

View file

@ -264,7 +264,7 @@ namespace MWMechanics
float directionX = nextPoint.mX - x;
float directionY = nextPoint.mY - y;
return osg::RadiansToDegrees(std::atan2(directionX, directionY));
return std::atan2(directionX, directionY);
}
bool PathFinder::checkPathCompleted(float x, float y, float tolerance)

View file

@ -40,7 +40,7 @@ namespace MWMechanics
bool checkPathCompleted(float x, float y, float tolerance = PathTolerance);
///< \Returns true if we are within \a tolerance units of the last path point.
/// In degrees
/// In radians
float getZAngleToNext(float x, float y) const;
bool isPathConstructed() const