Fix Android node selection distance (#6187)
authorDániel Juhász <juhdanad@gmail.com>
Thu, 24 Aug 2017 06:31:33 +0000 (06:31 +0000)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
src/game.cpp
src/touchscreengui.h

index 68acc81b7400dbcf2586c009c9781f0b35748240..facc68aeaaca452eb7ad0b06c69d31840627c9e9 100644 (file)
@@ -3550,6 +3550,9 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
 
        if ((g_settings->getBool("touchtarget")) && (g_touchscreengui)) {
                shootline = g_touchscreengui->getShootline();
+               // Scale shootline to the acual distance the player can reach
+               shootline.end = shootline.start
+                       + shootline.getVector().normalize() * BS * d;
                shootline.start += intToFloat(camera_offset, BS);
                shootline.end += intToFloat(camera_offset, BS);
        }
index f4f1766c91042e1db53788d0b86535ebc7ff3b10..1f680ccb28acd740a7bb72b79d38ce5e8b73611d 100644 (file)
@@ -156,6 +156,14 @@ public:
 
        double getPitch() { return m_camera_pitch; }
 
+       /*!
+        * Returns a line which describes what the player is pointing at.
+        * The starting point and looking direction are significant,
+        * the line should be scaled to match its length to the actual distance
+        * the player can reach.
+        * The line starts at the camera and ends on the camera's far plane.
+        * The coordinates do not contain the camera offset.
+        */
        line3d<f32> getShootline() { return m_shootline; }
 
        void step(float dtime);
@@ -180,6 +188,12 @@ private:
        double m_camera_yaw_change;
        double m_camera_pitch;
 
+       /*!
+        * A line starting at the camera and pointing towards the
+        * selected object.
+        * The line ends on the camera's far plane.
+        * The coordinates do not contain the camera offset.
+        */
        line3d<f32> m_shootline;
 
        rect<s32> m_control_pad_rect;