Skip to content

Commit 695d9ed

Browse files
srifqiSmallJoker
authored andcommittedApr 27, 2019
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.
1 parent f409f44 commit 695d9ed

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎src/client/game.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -2961,10 +2961,15 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
29612961
hlist ? hlist->getItem(0).getDefinition(itemdef_manager) : itemdef_manager->get("");
29622962

29632963
v3f player_position = player->getPosition();
2964+
v3f player_eye_position = player->getEyePosition();
29642965
v3f camera_position = camera->getPosition();
29652966
v3f camera_direction = camera->getDirection();
29662967
v3s16 camera_offset = camera->getOffset();
29672968

2969+
if (camera->getCameraMode() == CAMERA_MODE_FIRST)
2970+
player_eye_position += player->eye_offset_first;
2971+
else
2972+
player_eye_position += player->eye_offset_third;
29682973

29692974
/*
29702975
Calculate what block is the crosshair pointing to
@@ -2981,11 +2986,11 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
29812986
core::line3d<f32> shootline;
29822987

29832988
if (camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT) {
2984-
shootline = core::line3d<f32>(camera_position,
2985-
camera_position + camera_direction * BS * d);
2989+
shootline = core::line3d<f32>(player_eye_position,
2990+
player_eye_position + camera_direction * BS * d);
29862991
} else {
29872992
// prevent player pointing anything in front-view
2988-
shootline = core::line3d<f32>(camera_position,camera_position);
2993+
shootline = core::line3d<f32>(camera_position, camera_position);
29892994
}
29902995

29912996
#ifdef HAVE_TOUCHSCREENGUI

0 commit comments

Comments
 (0)
Please sign in to comment.