Attend to review, re-arrange blank lines, update lua_api.txt
authorparamat <paramat@users.noreply.github.com>
Wed, 10 Apr 2019 19:33:54 +0000 (20:33 +0100)
committerParamat <paramat@users.noreply.github.com>
Sun, 14 Apr 2019 21:21:51 +0000 (22:21 +0100)
doc/lua_api.txt
src/client/content_cao.cpp
src/content_sao.cpp

index 870daba025d97f0af423f12509fde8d937093aa7..c7035bb7282cf9431199352bc8c43c9f9c65a769 100644 (file)
@@ -5680,7 +5680,7 @@ Used by `ObjectRef` methods. Part of an Entity definition.
 
         automatic_face_movement_max_rotation_per_sec = -1,
         -- Limit automatic rotation to this value in degrees per second.
-        -- No limit if value < 0.
+        -- No limit if value <= 0.
 
         backface_culling = true,
         -- Set to false to disable backface_culling for model
index 22f62e6c3cf941c5adbf0af0b68f7cfbbe224dbb..b169ba75f73d909458cc68e11061d03015b1e78f 100644 (file)
@@ -997,21 +997,20 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
 
        if (!getParent() && m_prop.automatic_face_movement_dir &&
                        (fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)) {
-
                float target_yaw = atan2(m_velocity.Z, m_velocity.X) * 180 / M_PI
                                + m_prop.automatic_face_movement_dir_offset;
                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.
+               if (max_rotation_per_sec > 0) {
+                       wrappedApproachShortest(m_rotation.Y, target_yaw,
+                               dtime * max_rotation_per_sec, 360.f);
+               } else {
+                       // Negative values of max_rotation_per_sec mean disabled.
                        m_rotation.Y = target_yaw;
+               }
 
                rot_translator.val_current = m_rotation;
-
                updateNodePos();
        }
 }
index 1fd890044109f3ed2a7fd9e165c39eb5dee5ed11..f0d7fbf5d6e73eeab647e8ae738ea4f6db5dccf2 100644 (file)
@@ -454,19 +454,19 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
 
                if (m_prop.automatic_face_movement_dir &&
                                (fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)) {
-
                        float target_yaw = atan2(m_velocity.Z, m_velocity.X) * 180 / M_PI
                                + m_prop.automatic_face_movement_dir_offset;
-
                        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.
+                               wrappedApproachShortest(m_rotation.Y, target_yaw,
+                                       dtime * max_rotation_per_sec, 360.f);
+                       } else {
+                               // Negative values of max_rotation_per_sec mean disabled.
                                m_rotation.Y = target_yaw;
+                       }
                }
        }