summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkilbith <kilbith@users.noreply.github.com>2017-06-27 11:26:13 +0200
committerLoïc Blot <loic.blot@unix-experience.fr>2017-06-27 11:26:37 +0200
commit48cd217e3b6f53af32802c1897ddd1914d215078 (patch)
tree6ebfa3e34c4134e0f3f3f5b180013202409adda1 /src
parent53a6b5439eac140bbbe76441a4d6a02590fadb2f (diff)
downloadminetest-48cd217e3b6f53af32802c1897ddd1914d215078.tar.gz
minetest-48cd217e3b6f53af32802c1897ddd1914d215078.tar.bz2
minetest-48cd217e3b6f53af32802c1897ddd1914d215078.zip
Fix arm inertia limit case
Diffstat (limited to 'src')
-rw-r--r--src/camera.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index 855bca3ad..2de76da19 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -197,13 +197,17 @@ void Camera::step(f32 dtime)
void Camera::addArmInertia(f32 player_yaw, f32 frametime)
{
- if (m_timer.X == 0.0f)
- m_cam_vel.X = std::fabs((m_last_cam_pos.X - player_yaw)) * 0.01f;
+ if (m_timer.X == 0.0f) {
+ // In the limit case where timer is 0 set a static velocity (generic case divide by zero)
+ m_cam_vel.X = 1.0001f;
+ }
else
m_cam_vel.X = std::fabs((m_last_cam_pos.X - player_yaw) / m_timer.X) * 0.01f;
- if (m_timer.Y == 0.0f)
- m_cam_vel.Y = std::fabs(m_last_cam_pos.Y - m_camera_direction.Y);
+ if (m_timer.Y == 0.0f) {
+ // In the limit case where timer is 0 set a static velocity (generic case divide by zero)
+ m_cam_vel.Y = 1.0001f;
+ }
else
m_cam_vel.Y = std::fabs((m_last_cam_pos.Y - m_camera_direction.Y) / m_timer.Y);