Fix regression in automatic_face_movement_max_rotation_per_sec
authorPedro Gimeno <pgimeno@users.noreply.notabug.org>
Thu, 4 Apr 2019 16:53:55 +0000 (18:53 +0200)
committerParamat <paramat@users.noreply.github.com>
Sun, 14 Apr 2019 21:21:51 +0000 (22:21 +0100)
Values <= 0 should make the yaw change instant. This worked in 0.4.16 but was broken in 089f59458286.

Per bug report by oil_boi_minetest on IRC.

src/client/content_cao.cpp
src/content_sao.cpp

index 8643b5824b031f3b27e9e45485cab0d2fc3a3b23..22f62e6c3cf941c5adbf0af0b68f7cfbbe224dbb 100644 (file)
@@ -1000,10 +1000,16 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
 
                float target_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;
+               float max_rotation_per_sec =
+                               m_prop.automatic_face_movement_max_rotation_per_sec;
+               if (max_rotation_per_sec > 0) {
+                       float max_rotation_delta = dtime * max_rotation_per_sec;
+
+                       wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
+               } else
+                       // Negative values of ...max_rotation_per_sec mean disabled.
+                       m_rotation.Y = target_yaw;
 
-               wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
                rot_translator.val_current = m_rotation;
 
                updateNodePos();
index 2f849d3fc878f5fe5fc78703c1da2246a8900937..1fd890044109f3ed2a7fd9e165c39eb5dee5ed11 100644 (file)
@@ -457,11 +457,16 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
 
                        float target_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;
 
-                       m_rotation.Y = wrapDegrees_0_360(m_rotation.Y);
-                       wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
+                       float max_rotation_per_sec =
+                                       m_prop.automatic_face_movement_max_rotation_per_sec;
+                       if (max_rotation_per_sec > 0) {
+                               float max_rotation_delta = dtime * max_rotation_per_sec;
+                               m_rotation.Y = wrapDegrees_0_360(m_rotation.Y);
+                               wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
+                       } else
+                               // Negative values of ...max_rotation_per_sec mean disabled.
+                               m_rotation.Y = target_yaw;
                }
        }