@@ -108,7 +108,7 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,
108
108
{
109
109
// Maximum radius of a block. The magic number is
110
110
// sqrt(3.0) / 2.0 in literal form.
111
- const f32 block_max_radius = 0.866025403784 * MAP_BLOCKSIZE * BS;
111
+ static constexpr const f32 block_max_radius = 0 .866025403784f * MAP_BLOCKSIZE * BS;
112
112
113
113
v3s16 blockpos_nodes = blockpos_b * MAP_BLOCKSIZE;
114
114
@@ -125,16 +125,16 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,
125
125
// Total distance
126
126
f32 d = MYMAX (0 , blockpos_relative.getLength () - block_max_radius);
127
127
128
- if (distance_ptr)
128
+ if (distance_ptr)
129
129
*distance_ptr = d;
130
130
131
131
// If block is far away, it's not in sight
132
- if (d > range)
132
+ if (d > range)
133
133
return false ;
134
134
135
135
// If block is (nearly) touching the camera, don't
136
136
// bother validating further (that is, render it anyway)
137
- if (d == 0 )
137
+ if (d == 0 )
138
138
return true ;
139
139
140
140
// Adjust camera position, for purposes of computing the angle,
@@ -166,12 +166,13 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,
166
166
s16 adjustDist (s16 dist, float zoom_fov)
167
167
{
168
168
// 1.775 ~= 72 * PI / 180 * 1.4, the default on the client
169
- const float default_fov = 1 .775f ;
169
+ static constexpr const float default_fov = 1 .775f / 2 . 0f ;
Has comments. Original line has comments. 170
170
// heuristic cut-off for zooming
171
- if (zoom_fov > default_fov / 2 . 0f )
171
+ if (zoom_fov > default_fov)
Has comments. Original line has comments. 172
172
return dist;
173
173
174
174
// new_dist = dist * ((1 - cos(FOV / 2)) / (1-cos(zoomFOV /2))) ^ (1/3)
175
- return round (dist * std::cbrt ((1 .0f - std::cos (default_fov / 2 .0f )) /
175
+ // note: FOV is calculated at compilation time
176
+ return round (dist * std::cbrt ((1 .0f - std::cos (default_fov)) /
Has comments. Original line has comments. 176
177
(1 .0f - std::cos (zoom_fov / 2 .0f ))));
177
178
}