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