Skip to content

Commit

Permalink
Fix TouchScreenGUI ignoring server-sent pitch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp authored and sfan5 committed Dec 20, 2023
1 parent 47e557b commit 04dc4a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/game.cpp
Expand Up @@ -2617,7 +2617,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);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/touchscreengui.cpp
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/gui/touchscreengui.h
Expand Up @@ -171,7 +171,11 @@ class TouchScreenGUI
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.
Expand Down Expand Up @@ -213,7 +217,7 @@ class TouchScreenGUI

// 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.
Expand Down

0 comments on commit 04dc4a1

Please sign in to comment.