Skip to content

Commit 0732bf7

Browse files
committed
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.
1 parent 166ded4 commit 0732bf7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/clientiface.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void RemoteClient::GetNextBlocks (
125125
if (playerspeed.getLength() > 1.0f * BS)
126126
playerspeeddir = playerspeed / playerspeed.getLength();
127127
// Predict to next block
128-
v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS;
128+
v3f playerpos_predicted = playerpos + playerspeeddir * (MAP_BLOCKSIZE * BS);
129129

130130
v3s16 center_nodepos = floatToInt(playerpos_predicted, BS);
131131

@@ -196,6 +196,14 @@ void RemoteClient::GetNextBlocks (
196196
s16 wanted_range = sao->getWantedRange() + 1;
197197
float camera_fov = sao->getFov();
198198

199+
// cos(angle between velocity and camera) * |velocity|
200+
// Limit to 0.0f in case player moves backwards.
201+
f32 dot = rangelim(camera_dir.dotProduct(playerspeed), 0.0f, 300.0f);
202+
203+
// Reduce the field of view when a player moves and looks forward.
204+
// limit max fov effect to 50%, 60% at 20n/s fly speed
205+
camera_fov = camera_fov / (1 + dot / 300.0f);
206+
199207
const s16 full_d_max = std::min(m_max_send_distance, wanted_range);
200208
const s16 d_opt = std::min(m_block_optimize_distance, wanted_range);
201209
const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;

0 commit comments

Comments
 (0)