From 0d372250c1ea0b254788c327d8c958e2fd07ea89 Mon Sep 17 00:00:00 2001 From: Gregor Parzefall Date: Tue, 19 Dec 2023 20:35:50 +0100 Subject: [PATCH] Fix TouchScreenGUI ignoring server-sent pitch changes --- src/client/game.cpp | 2 +- src/gui/touchscreengui.cpp | 2 +- src/gui/touchscreengui.h | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/game.cpp b/src/client/game.cpp index cc8891547..38fd1ddbf 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2616,7 +2616,7 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime) #ifdef HAVE_TOUCHSCREENGUI if (g_touchscreengui) { cam->camera_yaw += g_touchscreengui->getYawChange(); - cam->camera_pitch = g_touchscreengui->getPitch(); + cam->camera_pitch += g_touchscreengui->getPitchChange(); } else { #endif v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2); diff --git a/src/gui/touchscreengui.cpp b/src/gui/touchscreengui.cpp index 4a6486573..bf8fc5afe 100644 --- a/src/gui/touchscreengui.cpp +++ b/src/gui/touchscreengui.cpp @@ -832,7 +832,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event) const double d = g_settings->getFloat("touchscreen_sensitivity", 0.001f, 10.0f) * 3.0f; m_camera_yaw_change -= dir_free.X * d; - m_camera_pitch = MYMIN(MYMAX(m_camera_pitch + (dir_free.Y * d), -180.0f), 180.0f); + m_camera_pitch_change += dir_free.Y * d; // update shootline // no need to update (X, Y) when using crosshair since the shootline is not used diff --git a/src/gui/touchscreengui.h b/src/gui/touchscreengui.h index ff5219f3a..b60edac79 100644 --- a/src/gui/touchscreengui.h +++ b/src/gui/touchscreengui.h @@ -171,7 +171,11 @@ public: return res; } - double getPitch() { return m_camera_pitch; } + double getPitchChange() { + double res = m_camera_pitch_change; + m_camera_pitch_change = 0; + return res; + } /** * Returns a line which describes what the player is pointing at. @@ -213,7 +217,7 @@ private: // value in degree double m_camera_yaw_change = 0.0; - double m_camera_pitch = 0.0; + double m_camera_pitch_change = 0.0; /** * A line starting at the camera and pointing towards the selected object.