mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-16 18:05:22 +02:00
Add support for limiting rotation of automatic face movement dir entitys
This commit is contained in:
@@ -1260,8 +1260,18 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
||||
if (getParent() == NULL && m_prop.automatic_face_movement_dir &&
|
||||
(fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001))
|
||||
{
|
||||
m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI
|
||||
float optimal_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;
|
||||
|
||||
if ((m_prop.automatic_face_movement_max_rotation_per_sec > 0) &&
|
||||
(fabs(m_yaw - optimal_yaw) > max_rotation_delta)) {
|
||||
|
||||
m_yaw = optimal_yaw < m_yaw ? m_yaw - max_rotation_delta : m_yaw + max_rotation_delta;
|
||||
} else {
|
||||
m_yaw = optimal_yaw;
|
||||
}
|
||||
updateNodePos();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user