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.
This commit is contained in:
swagtoy 2024-06-27 02:41:15 -04:00
parent 96ea24ffef
commit 1f52edb14c
2 changed files with 9 additions and 2 deletions

@ -228,7 +228,9 @@ class Camera
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;

@ -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);