aboutsummaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-03 13:35:09 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-03 13:35:09 +0200
commit339b7588d2f97ee96d0c9fcaabc862e223b9ae76 (patch)
tree66bfdd489f729317979fc1d8e7b093f88828f656 /src/map.cpp
parent0ac5f6a7ca2854814b7676a73eb186cf60eb0c98 (diff)
downloadminetest-339b7588d2f97ee96d0c9fcaabc862e223b9ae76.tar.gz
minetest-339b7588d2f97ee96d0c9fcaabc862e223b9ae76.tar.bz2
minetest-339b7588d2f97ee96d0c9fcaabc862e223b9ae76.zip
Tune occlusion culling a bit
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/map.cpp b/src/map.cpp
index e2ac5a231..3ecdfa00f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -3613,7 +3613,7 @@ void ClientMap::OnRegisterSceneNode()
ISceneNode::OnRegisterSceneNode();
}
-static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step,
+static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac,
float start_off, float end_off, u32 needed_count)
{
float d0 = (float)BS * p0.getDistanceFrom(p1);
@@ -3637,6 +3637,7 @@ static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step,
if(count >= needed_count)
return true;
}
+ step *= stepfac;
}
return false;
}
@@ -3845,31 +3846,32 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
v3s16 cpn = v3s16(block->getPos() * MAP_BLOCKSIZE)
+ v3s16(MAP_BLOCKSIZE)/2;
- float step = BS*2;
- float startoff = BS*3;
+ float step = BS*1;
+ float stepfac = 1.2;
+ float startoff = BS*1;
float endoff = -BS*MAP_BLOCKSIZE*1.42*1.42;
v3s16 spn = cam_pos_nodes + v3s16(0,0,0);
s16 bs2 = MAP_BLOCKSIZE/2 + 1;
u32 needed_count = 1;
if(
isOccluded(this, spn, cpn + v3s16(0,0,0),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2),
- step, startoff, endoff, needed_count) &&
+ step, stepfac, startoff, endoff, needed_count) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2),
- step, startoff, endoff, needed_count)
+ step, stepfac, startoff, endoff, needed_count)
)
{
blocks_occlusion_culled++;