Skip to content

Commit c05aac3

Browse files
committedNov 9, 2016
Occlusion culling: Add comments, minor code improvements
Remove unnecessary code. Use '/ 2.0f' because endoff is a float.
1 parent c793700 commit c05aac3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎src/clientmap.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,19 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
293293
float step = BS * 1;
294294
float stepfac = 1.1;
295295
float startoff = BS * 1;
296-
// - Length of the diagonal of a mapblock.
296+
// The occlusion search of 'isOccluded()' must stop short of the target
297+
// point by distance 'endoff' (end offset) to not enter the target mapblock.
298+
// For the 8 mapblock corners 'endoff' must therefore be the maximum diagonal
299+
// of a mapblock, because we must consider all view angles.
300+
// sqrt(1^2 + 1^2 + 1^2) = 1.732
297301
float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569;
298-
v3s16 spn = cam_pos_nodes + v3s16(0, 0, 0);
302+
v3s16 spn = cam_pos_nodes;
299303
s16 bs2 = MAP_BLOCKSIZE / 2 + 1;
300304
u32 needed_count = 1;
301305
if (occlusion_culling_enabled &&
302-
isOccluded(this, spn, cpn + v3s16(0, 0, 0),
303-
step, stepfac, startoff, endoff / 2, needed_count, nodemgr) &&
306+
// For the central point of the mapblock 'endoff' can be halved
307+
isOccluded(this, spn, cpn,
308+
step, stepfac, startoff, endoff / 2.0f, needed_count, nodemgr) &&
304309
isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
305310
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
306311
isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),

0 commit comments

Comments
 (0)
Please sign in to comment.