#4 Fix regression in automatic_face_movement_max_rotation_per_sec

Aperto
pgimeno vorrebbe unire 3 commit da pgimeno/pg-fix-max-omega a pgimeno/master
3 ha cambiato i file con 20 aggiunte e 8 eliminazioni
  1. 1 1
      doc/lua_api.txt
  2. 9 3
      src/client/content_cao.cpp
  3. 10 4
      src/content_sao.cpp

+ 1 - 1
doc/lua_api.txt

@@ -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

+ 9 - 3
src/client/content_cao.cpp

@@ -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)
+			wrappedApproachShortest(m_rotation.Y, target_yaw,
+					dtime * max_rotation_per_sec, 360.f);
+		else {
+			// Non-positive 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();

+ 10 - 4
src/content_sao.cpp

@@ -457,11 +457,17 @@ 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) {
+				m_rotation.Y = wrapDegrees_0_360(m_rotation.Y);
+				wrappedApproachShortest(m_rotation.Y, target_yaw,
+						dtime * max_rotation_per_sec, 360.f);
+			} else {
+				// Non-positive values of max_rotation_per_sec mean disabled.
+				m_rotation.Y = target_yaw;
+			}
 		}
 	}