1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-12 16:58:39 +00:00

Smoothed yaw rotation for objects (#6825)

This commit is contained in:
SmallJoker 2018-08-03 00:25:37 +02:00 committed by Paramat
parent 741e3efaf5
commit f3997025fd
4 changed files with 89 additions and 52 deletions

View file

@ -443,14 +443,9 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
+ m_prop.automatic_face_movement_dir_offset;
float max_rotation_delta =
dtime * m_prop.automatic_face_movement_max_rotation_per_sec;
float delta = wrapDegrees_0_360(target_yaw - m_yaw);
if (delta > max_rotation_delta && 360 - delta > max_rotation_delta) {
m_yaw += (delta < 180) ? max_rotation_delta : -max_rotation_delta;
m_yaw = wrapDegrees_0_360(m_yaw);
} else {
m_yaw = target_yaw;
}
m_yaw = wrapDegrees_0_360(m_yaw);
wrappedApproachShortest(m_yaw, target_yaw, max_rotation_delta, 360.f);
}
}