aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPedro Gimeno <pgimeno@users.noreply.notabug.org>2019-04-04 18:53:55 +0200
committerParamat <paramat@users.noreply.github.com>2019-04-14 22:21:51 +0100
commit12a63021d01abd7395be3614767648d0b39f42a3 (patch)
treecadd476c22038b0b9b76bc914b9488a1c7f61b95 /src
parent007ce24a111372ddd0d4d5a9fbe862cea430fa4b (diff)
downloadminetest-12a63021d01abd7395be3614767648d0b39f42a3.tar.gz
minetest-12a63021d01abd7395be3614767648d0b39f42a3.tar.bz2
minetest-12a63021d01abd7395be3614767648d0b39f42a3.zip
Fix regression in automatic_face_movement_max_rotation_per_sec
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.
Diffstat (limited to 'src')
-rw-r--r--src/client/content_cao.cpp12
-rw-r--r--src/content_sao.cpp13
2 files changed, 18 insertions, 7 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index 8643b5824..22f62e6c3 100644
--- a/src/client/content_cao.cpp
+++ b/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) {
+ 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();
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 2f849d3fc..1fd890044 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -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;
}
}