mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix rendering glitches when far from the center of the map
This commit is contained in:
parent
8e15179e7d
commit
062de11b4c
17 changed files with 112 additions and 35 deletions
28
src/game.cpp
28
src/game.cpp
|
@ -228,6 +228,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
|||
core::line3d<f32> shootline, f32 d,
|
||||
bool liquids_pointable,
|
||||
bool look_for_object,
|
||||
v3s16 camera_offset,
|
||||
std::vector<aabb3f> &hilightboxes,
|
||||
ClientActiveObject *&selected_object)
|
||||
{
|
||||
|
@ -258,8 +259,8 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
|||
|
||||
v3f pos = selected_object->getPosition();
|
||||
hilightboxes.push_back(aabb3f(
|
||||
selection_box->MinEdge + pos,
|
||||
selection_box->MaxEdge + pos));
|
||||
selection_box->MinEdge + pos - intToFloat(camera_offset, BS),
|
||||
selection_box->MaxEdge + pos - intToFloat(camera_offset, BS)));
|
||||
}
|
||||
|
||||
mindistance = (selected_object->getPosition() - camera_position).getLength();
|
||||
|
@ -361,8 +362,8 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
|||
i2 != boxes.end(); i2++)
|
||||
{
|
||||
aabb3f box = *i2;
|
||||
box.MinEdge += npf + v3f(-d,-d,-d);
|
||||
box.MaxEdge += npf + v3f(d,d,d);
|
||||
box.MinEdge += npf + v3f(-d,-d,-d) - intToFloat(camera_offset, BS);
|
||||
box.MaxEdge += npf + v3f(d,d,d) - intToFloat(camera_offset, BS);
|
||||
hilightboxes.push_back(box);
|
||||
}
|
||||
}
|
||||
|
@ -2541,6 +2542,8 @@ void the_game(
|
|||
Update camera
|
||||
*/
|
||||
|
||||
v3s16 old_camera_offset = camera.getOffset();
|
||||
|
||||
LocalPlayer* player = client.getEnv().getLocalPlayer();
|
||||
float full_punch_interval = playeritem_toolcap.full_punch_interval;
|
||||
float tool_reload_ratio = time_from_last_punch / full_punch_interval;
|
||||
|
@ -2554,10 +2557,19 @@ void the_game(
|
|||
v3f camera_position = camera.getPosition();
|
||||
v3f camera_direction = camera.getDirection();
|
||||
f32 camera_fov = camera.getFovMax();
|
||||
v3s16 camera_offset = camera.getOffset();
|
||||
|
||||
bool camera_offset_changed = (camera_offset != old_camera_offset);
|
||||
|
||||
if(!disable_camera_update){
|
||||
client.getEnv().getClientMap().updateCamera(camera_position,
|
||||
camera_direction, camera_fov);
|
||||
camera_direction, camera_fov, camera_offset);
|
||||
if (camera_offset_changed){
|
||||
client.updateCameraOffset(camera_offset);
|
||||
client.getEnv().updateCameraOffset(camera_offset);
|
||||
if (clouds)
|
||||
clouds->updateCameraOffset(camera_offset);
|
||||
}
|
||||
}
|
||||
|
||||
// Update sound listener
|
||||
|
@ -2600,6 +2612,7 @@ void the_game(
|
|||
&client, player_position, camera_direction,
|
||||
camera_position, shootline, d,
|
||||
playeritem_def.liquids_pointable, !ldown_for_dig,
|
||||
camera_offset,
|
||||
// output
|
||||
hilightboxes,
|
||||
selected_object);
|
||||
|
@ -3030,7 +3043,7 @@ void the_game(
|
|||
Update particles
|
||||
*/
|
||||
|
||||
allparticles_step(dtime, client.getEnv());
|
||||
allparticles_step(dtime);
|
||||
allparticlespawners_step(dtime, client.getEnv());
|
||||
|
||||
/*
|
||||
|
@ -3249,7 +3262,8 @@ void the_game(
|
|||
*/
|
||||
update_draw_list_timer += dtime;
|
||||
if(update_draw_list_timer >= 0.2 ||
|
||||
update_draw_list_last_cam_dir.getDistanceFrom(camera_direction) > 0.2){
|
||||
update_draw_list_last_cam_dir.getDistanceFrom(camera_direction) > 0.2 ||
|
||||
camera_offset_changed){
|
||||
update_draw_list_timer = 0;
|
||||
client.getEnv().getClientMap().updateDrawList(driver);
|
||||
update_draw_list_last_cam_dir = camera_direction;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue