Skip to content

Commit ce5b093

Browse files
authoredApr 23, 2020
Camera: Fix shootline line offsets II (#9730)
1 parent 6ba44d7 commit ce5b093

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
 

Diff for: ‎src/client/game.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,6 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
30293029
{
30303030
LocalPlayer *player = client->getEnv().getLocalPlayer();
30313031

3032-
const v3f head_position = camera->getHeadPosition();
30333032
const v3f camera_direction = camera->getDirection();
30343033
const v3s16 camera_offset = camera->getOffset();
30353034

@@ -3045,13 +3044,22 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
30453044

30463045
core::line3d<f32> shootline;
30473046

3048-
if (camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT) {
3049-
shootline = core::line3d<f32>(head_position,
3050-
head_position + camera_direction * BS * d);
3051-
} else {
3047+
switch (camera->getCameraMode()) {
3048+
case CAMERA_MODE_FIRST:
3049+
// Shoot from camera position, with bobbing
3050+
shootline.start = camera->getPosition();
3051+
break;
3052+
case CAMERA_MODE_THIRD:
3053+
// Shoot from player head, no bobbing
3054+
shootline.start = camera->getHeadPosition();
3055+
break;
3056+
case CAMERA_MODE_THIRD_FRONT:
3057+
shootline.start = camera->getHeadPosition();
30523058
// prevent player pointing anything in front-view
3053-
shootline = core::line3d<f32>(head_position, head_position);
3059+
d = 0;
3060+
break;
30543061
}
3062+
shootline.end = shootline.start + camera_direction * BS * d;
30553063

30563064
#ifdef HAVE_TOUCHSCREENGUI
30573065

0 commit comments

Comments
 (0)