summaryrefslogtreecommitdiff
path: root/src/content_cao.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r--src/content_cao.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index ed4e3b713..1b8e84c8f 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1260,8 +1260,18 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
if (getParent() == NULL && m_prop.automatic_face_movement_dir &&
(fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001))
{
- m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI
+ float optimal_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI
+ m_prop.automatic_face_movement_dir_offset;
+ float max_rotation_delta =
+ dtime * m_prop.automatic_face_movement_max_rotation_per_sec;
+
+ if ((m_prop.automatic_face_movement_max_rotation_per_sec > 0) &&
+ (fabs(m_yaw - optimal_yaw) > max_rotation_delta)) {
+
+ m_yaw = optimal_yaw < m_yaw ? m_yaw - max_rotation_delta : m_yaw + max_rotation_delta;
+ } else {
+ m_yaw = optimal_yaw;
+ }
updateNodePos();
}
}