forked from Mirrorlandia_minetest/minetest
Use server's zoom fov for distant world loading.
This commit is contained in:
parent
935f11a602
commit
a1868e8f6c
@ -196,30 +196,19 @@ void RemoteClient::GetNextBlocks (
|
|||||||
s16 wanted_range = sao->getWantedRange() + 1;
|
s16 wanted_range = sao->getWantedRange() + 1;
|
||||||
float camera_fov = sao->getFov();
|
float camera_fov = sao->getFov();
|
||||||
|
|
||||||
// If below the heuristic zoom threshold (see adjustDist() in numeric.cpp)
|
// Distrust client-sent FOV and get server-set player object property
|
||||||
// distrust client-sent FOV and get server-set player object property
|
|
||||||
// zoom FOV (degrees) as a check to avoid hacked clients using FOV to load
|
// zoom FOV (degrees) as a check to avoid hacked clients using FOV to load
|
||||||
// distant world.
|
// distant world.
|
||||||
// 0.888 radians is slightly larger than the zoom threshold of 1.775 / 2
|
float prop_zoom_fov = sao->getZoomFOV() * core::DEGTORAD;
|
||||||
// radians.
|
|
||||||
if (camera_fov < 0.888f) {
|
|
||||||
float prop_zoom_fov = sao->getZoomFOV();
|
|
||||||
// If zoom is disabled by value 0
|
|
||||||
if (prop_zoom_fov < 0.001f)
|
|
||||||
camera_fov = 0.888f;
|
|
||||||
else
|
|
||||||
// Degrees -> radians
|
|
||||||
camera_fov = prop_zoom_fov * core::DEGTORAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
const s16 full_d_max = std::min(adjustDist(m_max_send_distance, camera_fov),
|
const s16 full_d_max = std::min(adjustDist(m_max_send_distance, prop_zoom_fov),
|
||||||
wanted_range);
|
wanted_range);
|
||||||
const s16 d_opt = std::min(adjustDist(m_block_optimize_distance, camera_fov),
|
const s16 d_opt = std::min(adjustDist(m_block_optimize_distance, prop_zoom_fov),
|
||||||
wanted_range);
|
wanted_range);
|
||||||
const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;
|
const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;
|
||||||
|
|
||||||
s16 d_max = full_d_max;
|
s16 d_max = full_d_max;
|
||||||
s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, camera_fov),
|
s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, prop_zoom_fov),
|
||||||
wanted_range);
|
wanted_range);
|
||||||
|
|
||||||
// Don't loop very much at a time, adjust with distance,
|
// Don't loop very much at a time, adjust with distance,
|
||||||
|
@ -168,7 +168,7 @@ s16 adjustDist(s16 dist, float zoom_fov)
|
|||||||
// 1.775 ~= 72 * PI / 180 * 1.4, the default FOV on the client.
|
// 1.775 ~= 72 * PI / 180 * 1.4, the default FOV on the client.
|
||||||
// The heuristic threshold for zooming is half of that.
|
// The heuristic threshold for zooming is half of that.
|
||||||
static constexpr const float threshold_fov = 1.775f / 2.0f;
|
static constexpr const float threshold_fov = 1.775f / 2.0f;
|
||||||
if (zoom_fov > threshold_fov)
|
if (zoom_fov < 0.001f || zoom_fov > threshold_fov)
|
||||||
return dist;
|
return dist;
|
||||||
|
|
||||||
return std::round(dist * std::cbrt((1.0f - std::cos(threshold_fov)) /
|
return std::round(dist * std::cbrt((1.0f - std::cos(threshold_fov)) /
|
||||||
|
Loading…
Reference in New Issue
Block a user