From 492a5aabefb1a25d6c497bb1c8e12201c6d36f1d Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 23 Jul 2016 20:51:48 +0200 Subject: Removed freelook mouse position offset. --- src/client/input.cc | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/client/input.cc b/src/client/input.cc index 3c1b423..7edc1c2 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -1010,30 +1010,18 @@ void frame() } if (mouse_control || freelook_control ) { - const float aim_square_size = math::min(render::State::width(), render::State::height()) * 0.5f; - - int l = mouse_x; - int h = mouse_y; - - if (freelook_control) - { - // mouse location is relative to where freelook was initiated - l -= freelook_control_x; - h -= freelook_control_y; - } - else - { - // mouse location is relative to the center of the screen - l -= (render::State::width() / 2); - h -= (render::State::height() / 2); - } + const float aim_square_size = 0.5f * math::min(render::State::width(), render::State::height()); + // mouse location is relative to the center of the screen + const int l = mouse_x - (render::State::width() / 2); + const int h = mouse_y - (render::State::height() / 2); + // direction - mouse_direction = float(-l) / math::min( 0.5f *(float)(render::State::width()), aim_square_size); + mouse_direction = float(-l) / aim_square_size; math::clamp(mouse_direction, -1.0f, 1.0f); // pitch - mouse_pitch = float(-h) / math::min (0.5f * (float)(render::State::height()), aim_square_size); + mouse_pitch = float(-h) / aim_square_size; math::clamp(mouse_pitch, -1.0f, 1.0f); if (freelook_control) @@ -1074,6 +1062,8 @@ void frame() } else if (mouse_control) { + // the base game overrides the actual direction and pitch controls + // mouse is controling direction switch (render::camera().mode()) { -- cgit v1.2.3