diff options
author | Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com> | 2019-04-27 17:44:56 +0700 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-04-27 12:44:56 +0200 |
commit | 695d9edcd423319038c2fec1e6503dd5282928c4 (patch) | |
tree | 3bc57dcb479de8167ee277b61544e3a0d86fdb95 /src | |
parent | f409f4476539f32dcce3ff6832be4bc48bd25634 (diff) | |
download | minetest-695d9edcd423319038c2fec1e6503dd5282928c4.tar.gz minetest-695d9edcd423319038c2fec1e6503dd5282928c4.tar.bz2 minetest-695d9edcd423319038c2fec1e6503dd5282928c4.zip |
Use player as starting point instead of camera when pointing node (#8261)
Same pointing area on both camera modes.
This fix is inapplicable for non-crosshair input.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/game.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp index 379f32949..0badda535 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2961,10 +2961,15 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug) hlist ? hlist->getItem(0).getDefinition(itemdef_manager) : itemdef_manager->get(""); v3f player_position = player->getPosition(); + v3f player_eye_position = player->getEyePosition(); v3f camera_position = camera->getPosition(); v3f camera_direction = camera->getDirection(); v3s16 camera_offset = camera->getOffset(); + if (camera->getCameraMode() == CAMERA_MODE_FIRST) + player_eye_position += player->eye_offset_first; + else + player_eye_position += player->eye_offset_third; /* Calculate what block is the crosshair pointing to @@ -2981,11 +2986,11 @@ 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>(camera_position, - camera_position + camera_direction * BS * d); + shootline = core::line3d<f32>(player_eye_position, + player_eye_position + camera_direction * BS * d); } else { // prevent player pointing anything in front-view - shootline = core::line3d<f32>(camera_position,camera_position); + shootline = core::line3d<f32>(camera_position, camera_position); } #ifdef HAVE_TOUCHSCREENGUI |