summaryrefslogtreecommitdiff
path: root/src/clientmap.cpp
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2016-11-08 16:07:56 +0000
committerparamat <mat.gregory@virginmedia.com>2016-11-09 00:09:35 +0000
commitc05aac3766e88530fcf5d38a8c25c994b792b324 (patch)
tree772af4a2c9bcbda1d2efea5541c5c0cab3a87ab3 /src/clientmap.cpp
parentc79370023b322df2195f80a2f2d2b5b142add2bb (diff)
downloadminetest-c05aac3766e88530fcf5d38a8c25c994b792b324.tar.gz
minetest-c05aac3766e88530fcf5d38a8c25c994b792b324.tar.bz2
minetest-c05aac3766e88530fcf5d38a8c25c994b792b324.zip
Occlusion culling: Add comments, minor code improvements
Remove unnecessary code. Use '/ 2.0f' because endoff is a float.
Diffstat (limited to 'src/clientmap.cpp')
-rw-r--r--src/clientmap.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/clientmap.cpp b/src/clientmap.cpp
index 1d856520b..8691cc0b2 100644
--- a/src/clientmap.cpp
+++ b/src/clientmap.cpp
@@ -293,14 +293,19 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
float step = BS * 1;
float stepfac = 1.1;
float startoff = BS * 1;
- // - Length of the diagonal of a mapblock.
+ // The occlusion search of 'isOccluded()' must stop short of the target
+ // point by distance 'endoff' (end offset) to not enter the target mapblock.
+ // For the 8 mapblock corners 'endoff' must therefore be the maximum diagonal
+ // of a mapblock, because we must consider all view angles.
+ // sqrt(1^2 + 1^2 + 1^2) = 1.732
float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569;
- v3s16 spn = cam_pos_nodes + v3s16(0, 0, 0);
+ v3s16 spn = cam_pos_nodes;
s16 bs2 = MAP_BLOCKSIZE / 2 + 1;
u32 needed_count = 1;
if (occlusion_culling_enabled &&
- isOccluded(this, spn, cpn + v3s16(0, 0, 0),
- step, stepfac, startoff, endoff / 2, needed_count, nodemgr) &&
+ // For the central point of the mapblock 'endoff' can be halved
+ isOccluded(this, spn, cpn,
+ step, stepfac, startoff, endoff / 2.0f, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),