From 1f52edb14ce7cbc468dfd51c4f52976cbacdbd2f Mon Sep 17 00:00:00 2001 From: swagtoy Date: Thu, 27 Jun 2024 02:41:15 -0400 Subject: [PATCH] Live FOV changes Probably should add a method for changing the FOV but I am tired. This also works with /set fov ###, so not sure why something like this isn't done already. --- src/client/camera.h | 2 ++ src/client/game.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/camera.h b/src/client/camera.h index 88533181b..0c432ac8d 100644 --- a/src/client/camera.h +++ b/src/client/camera.h @@ -228,7 +228,9 @@ private: Client *m_client; // Default Client FOV (as defined by the "fov" setting) +public: // TODO make a setter f32 m_cache_fov; +private: // Absolute camera position v3f m_camera_position; diff --git a/src/client/game.cpp b/src/client/game.cpp index 62949b489..68ce6067d 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -202,7 +202,6 @@ struct LocalFormspecHandler : public TextDest if (i.first.rfind("page_", 0) == 0) { m_client->getScript()->show_settings(i.first.substr(5)); - std::cout << "Found ..." << m_client << std::endl; } //std::cout << "Setting " << i.first << " set!" << std::endl; @@ -1041,6 +1040,8 @@ Game::Game() : &settingChangedCallback, this); g_settings->registerChangedCallback("pause_on_lost_focus", &settingChangedCallback, this); + g_settings->registerChangedCallback("fov", + &settingChangedCallback, this); readSettings(); } @@ -4441,13 +4442,17 @@ void Game::readSettings() m_cache_enable_noclip = g_settings->getBool("noclip"); m_cache_enable_free_move = g_settings->getBool("free_move"); + m_cache_cam_smoothing = 0; if (g_settings->getBool("cinematic")) m_cache_cam_smoothing = 1 - g_settings->getFloat("cinematic_camera_smoothing"); else m_cache_cam_smoothing = 1 - g_settings->getFloat("camera_smoothing"); - + + if (camera) + camera->m_cache_fov = g_settings->getFloat("fov"); + m_cache_cam_smoothing = rangelim(m_cache_cam_smoothing, 0.01f, 1.0f); m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0);