Skip to content

Commit 48cd217

Browse files
kilbithnerzhul
authored andcommittedJun 27, 2017
Fix arm inertia limit case
1 parent 53a6b54 commit 48cd217

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

Diff for: ‎src/camera.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,17 @@ void Camera::step(f32 dtime)
197197

198198
void Camera::addArmInertia(f32 player_yaw, f32 frametime)
199199
{
200-
if (m_timer.X == 0.0f)
201-
m_cam_vel.X = std::fabs((m_last_cam_pos.X - player_yaw)) * 0.01f;
200+
if (m_timer.X == 0.0f) {
201+
// In the limit case where timer is 0 set a static velocity (generic case divide by zero)
202+
m_cam_vel.X = 1.0001f;
203+
}
202204
else
203205
m_cam_vel.X = std::fabs((m_last_cam_pos.X - player_yaw) / m_timer.X) * 0.01f;
204206

205-
if (m_timer.Y == 0.0f)
206-
m_cam_vel.Y = std::fabs(m_last_cam_pos.Y - m_camera_direction.Y);
207+
if (m_timer.Y == 0.0f) {
208+
// In the limit case where timer is 0 set a static velocity (generic case divide by zero)
209+
m_cam_vel.Y = 1.0001f;
210+
}
207211
else
208212
m_cam_vel.Y = std::fabs((m_last_cam_pos.Y - m_camera_direction.Y) / m_timer.Y);
209213

0 commit comments

Comments
 (0)
Please sign in to comment.