aboutsummaryrefslogtreecommitdiff
path: root/src/client/game.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2020-04-23 12:16:36 +0200
committerGitHub <noreply@github.com>2020-04-23 12:16:36 +0200
commitce5b0932f8e17244bd6c1e307f1fce76b16e6474 (patch)
tree45f9c53a91b21fa9584b421160cb7687eb33445c /src/client/game.cpp
parent6ba44d74526031a07bbc5093b708b8b99a27456a (diff)
downloadminetest-ce5b0932f8e17244bd6c1e307f1fce76b16e6474.tar.gz
minetest-ce5b0932f8e17244bd6c1e307f1fce76b16e6474.tar.bz2
minetest-ce5b0932f8e17244bd6c1e307f1fce76b16e6474.zip
Camera: Fix shootline line offsets II (#9730)
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r--src/client/game.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 4b2d7c652..3429cc57b 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -3029,7 +3029,6 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
{
LocalPlayer *player = client->getEnv().getLocalPlayer();
- const v3f head_position = camera->getHeadPosition();
const v3f camera_direction = camera->getDirection();
const v3s16 camera_offset = camera->getOffset();
@@ -3045,13 +3044,22 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
core::line3d<f32> shootline;
- if (camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT) {
- shootline = core::line3d<f32>(head_position,
- head_position + camera_direction * BS * d);
- } else {
+ switch (camera->getCameraMode()) {
+ case CAMERA_MODE_FIRST:
+ // Shoot from camera position, with bobbing
+ shootline.start = camera->getPosition();
+ break;
+ case CAMERA_MODE_THIRD:
+ // Shoot from player head, no bobbing
+ shootline.start = camera->getHeadPosition();
+ break;
+ case CAMERA_MODE_THIRD_FRONT:
+ shootline.start = camera->getHeadPosition();
// prevent player pointing anything in front-view
- shootline = core::line3d<f32>(head_position, head_position);
+ d = 0;
+ break;
}
+ shootline.end = shootline.start + camera_direction * BS * d;
#ifdef HAVE_TOUCHSCREENGUI