summaryrefslogtreecommitdiff
path: root/src/clientmap.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-12-22 23:16:00 +0100
committerest31 <MTest31@outlook.com>2016-12-22 23:16:00 +0100
commit81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (patch)
tree1e9ef1be1b3295a8673d6e4f0bdeb4c2d3a6015f /src/clientmap.cpp
parent8077612dcb48221281e726a60eb97bf73fde462b (diff)
parent231ac33d34dfaaddf292c5f31b1eae43eeefba2d (diff)
downloadminetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.gz
minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.bz2
minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.zip
Merge 0.4.15 changes into stable-0.4
0.4.15 release!
Diffstat (limited to 'src/clientmap.cpp')
-rw-r--r--src/clientmap.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/clientmap.cpp b/src/clientmap.cpp
index a0a780250..faa1461f6 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;
}
@@ -293,13 +293,22 @@ 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;
- v3s16 spn = cam_pos_nodes + v3s16(0, 0, 0);
+ // 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;
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 &&
- isOccluded(this, spn, cpn + v3s16(0, 0, 0),
- step, stepfac, startoff, endoff, 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),
@@ -521,6 +530,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 =