Occlusion culling: Fix 'end offset' distance, half this for centre point
authorLars Hofhansl <larsh@apache.org>
Fri, 4 Nov 2016 07:13:17 +0000 (00:13 -0700)
committerparamat <mat.gregory@virginmedia.com>
Tue, 8 Nov 2016 15:12:08 +0000 (15:12 +0000)
'endoff', the maximum diagonal of a mapblock, was incorrectly calculated.
Half this value for the centre point of the mapblock.

src/clientmap.cpp

index 60170ab704c4f21b8aa908482cbed30f1d5c7732..1d856520b7aaa0e2e146f04cd8d33a6a47621a5a 100644 (file)
@@ -293,13 +293,14 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
                        float step = BS * 1;
                        float stepfac = 1.1;
                        float startoff = BS * 1;
-                       float endoff = -BS*MAP_BLOCKSIZE * 1.42 * 1.42;
+                       // - Length of the diagonal of a mapblock.
+                       float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569;
                        v3s16 spn = cam_pos_nodes + v3s16(0, 0, 0);
                        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, needed_count, nodemgr) &&
+                                               step, stepfac, startoff, endoff / 2, 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),