From b8292319924994352d56d6111faa73fe315d149a Mon Sep 17 00:00:00 2001 From: lhofhansl Date: Fri, 28 Oct 2022 09:52:54 -0700 Subject: [PATCH] Fix incorrect culling introduced by ##12710 (#12887) --- src/client/clientmap.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index b74499ac3..3b6a319f3 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -259,11 +259,13 @@ void ClientMap::updateDrawList() } v3s16 block_coord = block->getPos(); - v3s16 block_position = block->getPosRelative() + MAP_BLOCKSIZE / 2; - - // First, perform a simple distance check, with a padding of one extra block. + v3f mesh_sphere_center = intToFloat(block->getPosRelative(), BS) + + block->mesh->getBoundingSphereCenter(); + f32 mesh_sphere_radius = block->mesh->getBoundingRadius(); + // First, perform a simple distance check. if (!m_control.range_all && - block_position.getDistanceFrom(cam_pos_nodes) > m_control.wanted_range) + mesh_sphere_center.getDistanceFrom(intToFloat(cam_pos_nodes, BS)) > + m_control.wanted_range * BS + mesh_sphere_radius) continue; // Out of range, skip. // Keep the block alive as long as it is in range. @@ -274,9 +276,6 @@ void ClientMap::updateDrawList() // Only do coarse culling here, to account for fast camera movement. // This is needed because this function is not called every frame. constexpr float frustum_cull_extra_radius = 300.0f; - v3f mesh_sphere_center = intToFloat(block->getPosRelative(), BS) - + block->mesh->getBoundingSphereCenter(); - f32 mesh_sphere_radius = block->mesh->getBoundingRadius(); if (is_frustum_culled(mesh_sphere_center, mesh_sphere_radius + frustum_cull_extra_radius)) continue;