diff options
author | Lars Hofhansl <larsh@apache.org> | 2017-10-25 23:10:33 -0700 |
---|---|---|
committer | Lars Hofhansl <larsh@apache.org> | 2017-10-25 23:13:06 -0700 |
commit | 0732bf73a4461792bc7b514d7cdbdc49114b5176 (patch) | |
tree | 2dda0fc32f386decf646fa3638829ad196b7067c | |
parent | 166ded4a11553447f8e08e0c71bb1a549fd65148 (diff) | |
download | minetest-0732bf73a4461792bc7b514d7cdbdc49114b5176.tar.gz minetest-0732bf73a4461792bc7b514d7cdbdc49114b5176.tar.bz2 minetest-0732bf73a4461792bc7b514d7cdbdc49114b5176.zip |
Reduce server FOV with forward speed
This causes blocks in front of the player to be rendered sooner and
blocks in the periphal view (that would soon be out of view) a bit later.
Overall this leads to smoother rendering as the player is moving around.
-rw-r--r-- | src/clientiface.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 404ce0d4e..bf0bdade0 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -125,7 +125,7 @@ void RemoteClient::GetNextBlocks ( if (playerspeed.getLength() > 1.0f * BS) playerspeeddir = playerspeed / playerspeed.getLength(); // Predict to next block - v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS; + v3f playerpos_predicted = playerpos + playerspeeddir * (MAP_BLOCKSIZE * BS); v3s16 center_nodepos = floatToInt(playerpos_predicted, BS); @@ -196,6 +196,14 @@ void RemoteClient::GetNextBlocks ( s16 wanted_range = sao->getWantedRange() + 1; float camera_fov = sao->getFov(); + // cos(angle between velocity and camera) * |velocity| + // Limit to 0.0f in case player moves backwards. + f32 dot = rangelim(camera_dir.dotProduct(playerspeed), 0.0f, 300.0f); + + // Reduce the field of view when a player moves and looks forward. + // limit max fov effect to 50%, 60% at 20n/s fly speed + camera_fov = camera_fov / (1 + dot / 300.0f); + const s16 full_d_max = std::min(m_max_send_distance, wanted_range); const s16 d_opt = std::min(m_block_optimize_distance, wanted_range); const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE; |