@@ -228,6 +228,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
228
228
core::line3d<f32> shootline, f32 d,
229
229
bool liquids_pointable,
230
230
bool look_for_object,
231
+ v3s16 camera_offset,
231
232
std::vector<aabb3f> &hilightboxes,
232
233
ClientActiveObject *&selected_object)
233
234
{
@@ -258,8 +259,8 @@ PointedThing getPointedThing(Client *client, v3f player_position,
258
259
259
260
v3f pos = selected_object->getPosition ();
260
261
hilightboxes.push_back (aabb3f (
261
- selection_box->MinEdge + pos,
262
- selection_box->MaxEdge + pos));
262
+ selection_box->MinEdge + pos - intToFloat (camera_offset, BS) ,
263
+ selection_box->MaxEdge + pos - intToFloat (camera_offset, BS) ));
263
264
}
264
265
265
266
mindistance = (selected_object->getPosition () - camera_position).getLength ();
@@ -361,8 +362,8 @@ PointedThing getPointedThing(Client *client, v3f player_position,
361
362
i2 != boxes.end (); i2++)
362
363
{
363
364
aabb3f box = *i2;
364
- box.MinEdge += npf + v3f (-d,-d,-d);
365
- box.MaxEdge += npf + v3f (d,d,d);
365
+ box.MinEdge += npf + v3f (-d,-d,-d) - intToFloat (camera_offset, BS) ;
366
+ box.MaxEdge += npf + v3f (d,d,d) - intToFloat (camera_offset, BS) ;
366
367
hilightboxes.push_back (box);
367
368
}
368
369
}
@@ -2541,6 +2542,8 @@ void the_game(
2541
2542
Update camera
2542
2543
*/
2543
2544
2545
+ v3s16 old_camera_offset = camera.getOffset ();
2546
+
2544
2547
LocalPlayer* player = client.getEnv ().getLocalPlayer ();
2545
2548
float full_punch_interval = playeritem_toolcap.full_punch_interval ;
2546
2549
float tool_reload_ratio = time_from_last_punch / full_punch_interval;
@@ -2554,10 +2557,19 @@ void the_game(
2554
2557
v3f camera_position = camera.getPosition ();
2555
2558
v3f camera_direction = camera.getDirection ();
2556
2559
f32 camera_fov = camera.getFovMax ();
2560
+ v3s16 camera_offset = camera.getOffset ();
2561
+
2562
+ bool camera_offset_changed = (camera_offset != old_camera_offset);
2557
2563
2558
2564
if (!disable_camera_update){
2559
2565
client.getEnv ().getClientMap ().updateCamera (camera_position,
2560
- camera_direction, camera_fov);
2566
+ camera_direction, camera_fov, camera_offset);
2567
+ if (camera_offset_changed){
2568
+ client.updateCameraOffset (camera_offset);
2569
+ client.getEnv ().updateCameraOffset (camera_offset);
2570
+ if (clouds)
2571
+ clouds->updateCameraOffset (camera_offset);
2572
+ }
2561
2573
}
2562
2574
2563
2575
// Update sound listener
@@ -2600,6 +2612,7 @@ void the_game(
2600
2612
&client, player_position, camera_direction,
2601
2613
camera_position, shootline, d,
2602
2614
playeritem_def.liquids_pointable , !ldown_for_dig,
2615
+ camera_offset,
2603
2616
// output
2604
2617
hilightboxes,
2605
2618
selected_object);
@@ -3030,7 +3043,7 @@ void the_game(
3030
3043
Update particles
3031
3044
*/
3032
3045
3033
- allparticles_step (dtime, client. getEnv () );
3046
+ allparticles_step (dtime);
3034
3047
allparticlespawners_step (dtime, client.getEnv ());
3035
3048
3036
3049
/*
@@ -3249,7 +3262,8 @@ void the_game(
3249
3262
*/
3250
3263
update_draw_list_timer += dtime;
3251
3264
if (update_draw_list_timer >= 0.2 ||
3252
- update_draw_list_last_cam_dir.getDistanceFrom (camera_direction) > 0.2 ){
3265
+ update_draw_list_last_cam_dir.getDistanceFrom (camera_direction) > 0.2 ||
3266
+ camera_offset_changed){
3253
3267
update_draw_list_timer = 0 ;
3254
3268
client.getEnv ().getClientMap ().updateDrawList (driver);
3255
3269
update_draw_list_last_cam_dir = camera_direction;
0 commit comments