From f8fd432dca9f84a489cb7033afc4e4eef7cff49d Mon Sep 17 00:00:00 2001 From: lhofhansl Date: Thu, 3 Nov 2016 19:14:32 -0700 Subject: Add debug priv, and allow player to display the scene as wire-frame. (#4709) --- src/clientmap.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/clientmap.cpp') diff --git a/src/clientmap.cpp b/src/clientmap.cpp index a0a780250..60170ab70 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -521,6 +521,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter); buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter); buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter); + buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe); const video::SMaterial& material = buf->getMaterial(); video::IMaterialRenderer* rnd = -- cgit v1.2.3 From 2b21cac1d80454bd23c5f60c4570b30edba62584 Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Fri, 4 Nov 2016 00:13:17 -0700 Subject: Occlusion culling: Fix 'end offset' distance, half this for centre point 'endoff', the maximum diagonal of a mapblock, was incorrectly calculated. Half this value for the centre point of the mapblock. --- src/clientmap.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/clientmap.cpp') diff --git a/src/clientmap.cpp b/src/clientmap.cpp index 60170ab70..1d856520b 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -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), -- cgit v1.2.3 From c05aac3766e88530fcf5d38a8c25c994b792b324 Mon Sep 17 00:00:00 2001 From: paramat Date: Tue, 8 Nov 2016 16:07:56 +0000 Subject: Occlusion culling: Add comments, minor code improvements Remove unnecessary code. Use '/ 2.0f' because endoff is a float. --- src/clientmap.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/clientmap.cpp') 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), -- cgit v1.2.3 From e4f7ce1985bda1c37b62f24d028828c5d3851ca2 Mon Sep 17 00:00:00 2001 From: lhofhansl Date: Sun, 18 Dec 2016 04:25:42 -0800 Subject: Fix occlusing counting (#4922) --- src/clientmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/clientmap.cpp') diff --git a/src/clientmap.cpp b/src/clientmap.cpp index 8691cc0b2..db71d4b57 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -132,9 +132,9 @@ static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac, else is_transparent = (f.solidness != 2); if(!is_transparent){ - if(count == needed_count) - return true; count++; + if(count >= needed_count) + return true; } step *= stepfac; } -- cgit v1.2.3 From 24edfb77afbb631cb83d26a095b609850f997e5c Mon Sep 17 00:00:00 2001 From: lhofhansl Date: Sun, 18 Dec 2016 21:43:04 -0800 Subject: Fix occlusion culling, again (#4930) --- src/clientmap.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/clientmap.cpp') diff --git a/src/clientmap.cpp b/src/clientmap.cpp index db71d4b57..faa1461f6 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -301,7 +301,10 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver) float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569; v3s16 spn = cam_pos_nodes; s16 bs2 = MAP_BLOCKSIZE / 2 + 1; - u32 needed_count = 1; + // to reduce the likelihood of falsely occluded blocks + // require at least two solid blocks + // this is a HACK, we should think of a more precise algorithm + u32 needed_count = 2; if (occlusion_culling_enabled && // For the central point of the mapblock 'endoff' can be halved isOccluded(this, spn, cpn, -- cgit v1.2.3