Skip to content

Commit

Permalink
Fix regression in automatic_face_movement_max_rotation_per_sec
Browse files Browse the repository at this point in the history
Values <= 0 should make the yaw change instant. This worked in 0.4.16 but was broken in 089f594.

Per bug report by oil_boi_minetest on IRC.
  • Loading branch information
Pedro Gimeno authored and paramat committed Apr 14, 2019
1 parent 007ce24 commit 12a6302
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/client/content_cao.cpp
Expand Up @@ -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();
Expand Down
13 changes: 9 additions & 4 deletions src/content_sao.cpp
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 12a6302

Please sign in to comment.