Skip to content

Commit 12a6302

Browse files
Pedro Gimenoparamat
Pedro Gimeno
authored andcommittedApr 14, 2019
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 089f594. Per bug report by oil_boi_minetest on IRC.
1 parent 007ce24 commit 12a6302

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed
 

Diff for: ‎src/client/content_cao.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,16 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
10001000

10011001
float target_yaw = atan2(m_velocity.Z, m_velocity.X) * 180 / M_PI
10021002
+ m_prop.automatic_face_movement_dir_offset;
1003-
float max_rotation_delta =
1004-
dtime * m_prop.automatic_face_movement_max_rotation_per_sec;
1003+
float max_rotation_per_sec =
1004+
m_prop.automatic_face_movement_max_rotation_per_sec;
1005+
if (max_rotation_per_sec > 0) {
1006+
float max_rotation_delta = dtime * max_rotation_per_sec;
1007+
1008+
wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
1009+
} else
1010+
// Negative values of ...max_rotation_per_sec mean disabled.
1011+
m_rotation.Y = target_yaw;
10051012

1006-
wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
10071013
rot_translator.val_current = m_rotation;
10081014

10091015
updateNodePos();

Diff for: ‎src/content_sao.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,16 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
457457

458458
float target_yaw = atan2(m_velocity.Z, m_velocity.X) * 180 / M_PI
459459
+ m_prop.automatic_face_movement_dir_offset;
460-
float max_rotation_delta =
461-
dtime * m_prop.automatic_face_movement_max_rotation_per_sec;
462460

463-
m_rotation.Y = wrapDegrees_0_360(m_rotation.Y);
464-
wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
461+
float max_rotation_per_sec =
462+
m_prop.automatic_face_movement_max_rotation_per_sec;
463+
if (max_rotation_per_sec > 0) {
464+
float max_rotation_delta = dtime * max_rotation_per_sec;
465+
m_rotation.Y = wrapDegrees_0_360(m_rotation.Y);
466+
wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
467+
} else
468+
// Negative values of ...max_rotation_per_sec mean disabled.
469+
m_rotation.Y = target_yaw;
465470
}
466471
}
467472

0 commit comments

Comments
 (0)