diff options
author | Paramat <paramat@users.noreply.github.com> | 2018-04-05 20:15:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-05 20:15:38 +0100 |
commit | c6975febbab02db306329a93d4ccc3249df209e3 (patch) | |
tree | 73ebba9c55c0be365f7773b03352d1b43df6d547 /src | |
parent | 32d456bd2d4dda50f77c01c702d1b5a5ff26134b (diff) | |
download | minetest-c6975febbab02db306329a93d4ccc3249df209e3.tar.gz minetest-c6975febbab02db306329a93d4ccc3249df209e3.tar.bz2 minetest-c6975febbab02db306329a93d4ccc3249df209e3.zip |
Zoom adjustDist(): Improve variable name (#7208)
Diffstat (limited to 'src')
-rw-r--r-- | src/util/numeric.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp index ddd4fd6cc..7264e5f89 100644 --- a/src/util/numeric.cpp +++ b/src/util/numeric.cpp @@ -165,14 +165,12 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, s16 adjustDist(s16 dist, float zoom_fov) { - // 1.775 ~= 72 * PI / 180 * 1.4, the default on the client - static constexpr const float default_fov = 1.775f / 2.0f; - // heuristic cut-off for zooming - if (zoom_fov > default_fov) + // 1.775 ~= 72 * PI / 180 * 1.4, the default FOV on the client. + // The heuristic threshold for zooming is half of that. + static constexpr const float threshold_fov = 1.775f / 2.0f; + if (zoom_fov > threshold_fov) return dist; - // new_dist = dist * ((1 - cos(FOV / 2)) / (1-cos(zoomFOV /2))) ^ (1/3) - // note: FOV is calculated at compilation time - return std::round(dist * std::cbrt((1.0f - std::cos(default_fov)) / + return std::round(dist * std::cbrt((1.0f - std::cos(threshold_fov)) / (1.0f - std::cos(zoom_fov / 2.0f)))); } |