1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00
OpenMW/apps/openmw/mwmechanics/steering.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1022 B
C++
Raw Normal View History

2014-01-29 20:29:07 +01:00
#ifndef OPENMW_MECHANICS_STEERING_H
2015-09-24 15:21:42 +02:00
#define OPENMW_MECHANICS_STEERING_H
2014-01-29 20:29:07 +01:00
2015-06-03 19:41:19 +02:00
#include <osg/Math>
2014-01-29 20:29:07 +01:00
#include <algorithm>
2014-01-29 20:29:07 +01:00
namespace MWWorld
{
class Ptr;
}
namespace MWMechanics
{
2014-04-20 20:35:07 +04:00
// Max rotating speed, radian/sec
inline float getAngularVelocity(const float actorSpeed)
{
constexpr float degreesPerFrame = 15.f;
constexpr int framesPerSecond = 60;
const float baseAngularVelocity = osg::DegreesToRadians(degreesPerFrame * framesPerSecond);
const float baseSpeed = 200;
return baseAngularVelocity * std::max(actorSpeed / baseSpeed, 1.0f);
}
2014-04-20 20:35:07 +04:00
2014-01-29 20:29:07 +01:00
/// configure rotation settings for an actor to reach this target angle (eventually)
/// @return have we reached the target angle?
2015-06-03 19:41:19 +02:00
bool zTurn(const MWWorld::Ptr& actor, float targetAngleRadians,
float epsilonRadians = osg::DegreesToRadians(0.5));
2014-01-29 20:29:07 +01:00
2015-06-03 19:41:19 +02:00
bool smoothTurn(const MWWorld::Ptr& actor, float targetAngleRadians, int axis,
float epsilonRadians = osg::DegreesToRadians(0.5));
2014-01-29 20:29:07 +01:00
}
#endif