1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Add support for per-player FOV overrides and multipliers

This commit is contained in:
Anand S 2018-07-15 05:56:30 +05:30 committed by sfan5
parent 5c9983400f
commit 47da640d77
13 changed files with 168 additions and 62 deletions

View file

@ -448,12 +448,26 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
if (m_camera_mode != CAMERA_MODE_FIRST)
m_camera_position = my_cp;
// Get FOV
/*
* Apply server-sent FOV. If server doesn't enforce FOV,
* check for zoom and set to zoom FOV.
* Otherwise, default to m_cache_fov
*/
f32 fov_degrees;
// Disable zoom with zoom FOV = 0
if (player->getPlayerControl().zoom && player->getZoomFOV() > 0.001f) {
PlayerFovSpec fov_spec = player->getFov();
if (fov_spec.fov > 0.0f) {
// If server-sent FOV is a multiplier, multiply
// it with m_cache_fov instead of overriding
if (fov_spec.is_multiplier)
fov_degrees = m_cache_fov * fov_spec.fov;
else
fov_degrees = fov_spec.fov;
} else if (player->getPlayerControl().zoom && player->getZoomFOV() > 0.001f) {
// Player requests zoom, apply zoom FOV
fov_degrees = player->getZoomFOV();
} else {
// Set to client's selected FOV
fov_degrees = m_cache_fov;
}
fov_degrees = rangelim(fov_degrees, 1.0f, 160.0f);