diff options
Diffstat (limited to 'src/camera.cpp')
-rw-r--r-- | src/camera.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/camera.cpp b/src/camera.cpp index 09e3c836a..db53cd5d9 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -97,6 +97,23 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, m_wieldnode->setItem(ItemStack(), m_gamedef); m_wieldnode->drop(); // m_wieldmgr grabbed it m_wieldlightnode = m_wieldmgr->addLightSceneNode(NULL, v3f(0.0, 50.0, 0.0)); + + /* TODO: Add a callback function so these can be updated when a setting + * changes. At this point in time it doesn't matter (e.g. /set + * is documented to change server settings only) + * + * TODO: Local caching of settings is not optimal and should at some stage + * be updated to use a global settings object for getting thse values + * (as opposed to the this local caching). This can be addressed in + * a later release. + */ + m_cache_fall_bobbing_amount = g_settings->getFloat("fall_bobbing_amount"); + m_cache_view_bobbing_amount = g_settings->getFloat("view_bobbing_amount"); + m_cache_viewing_range_min = g_settings->getFloat("viewing_range_nodes_min"); + m_cache_viewing_range_max = g_settings->getFloat("viewing_range_nodes_max"); + m_cache_wanted_fps = g_settings->getFloat("wanted_fps"); + m_cache_fov = g_settings->getFloat("fov"); + m_cache_view_bobbing = g_settings->getBool("view_bobbing"); } Camera::~Camera() @@ -283,7 +300,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, // Amplify according to the intensity of the impact fall_bobbing *= (1 - rangelim(50 / player->camera_impact, 0, 1)) * 5; - fall_bobbing *= g_settings->getFloat("fall_bobbing_amount"); + fall_bobbing *= m_cache_fall_bobbing_amount; } // Calculate players eye offset for different camera modes @@ -322,7 +339,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, //rel_cam_target += 0.03 * bobvec; //rel_cam_up.rotateXYBy(0.02 * bobdir * bobtmp * M_PI); float f = 1.0; - f *= g_settings->getFloat("view_bobbing_amount"); + f *= m_cache_view_bobbing_amount; rel_cam_pos += bobvec * f; //rel_cam_target += 0.995 * bobvec * f; rel_cam_target += bobvec * f; @@ -410,7 +427,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, m_camera_position = my_cp; // Get FOV setting - f32 fov_degrees = g_settings->getFloat("fov"); + f32 fov_degrees = m_cache_fov; fov_degrees = MYMAX(fov_degrees, 10.0); fov_degrees = MYMIN(fov_degrees, 170.0); @@ -482,7 +499,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, v3f speed = player->getSpeed(); if ((hypot(speed.X, speed.Z) > BS) && (player->touching_ground) && - (g_settings->getBool("view_bobbing") == true) && + (m_cache_view_bobbing == true) && (g_settings->getBool("free_move") == false || !m_gamedef->checkLocalPrivilege("fly"))) { @@ -522,10 +539,10 @@ void Camera::updateViewingRange(f32 frametime_in, f32 busytime_in) <<std::endl;*/ // Get current viewing range and FPS settings - f32 viewing_range_min = g_settings->getS16("viewing_range_nodes_min"); + f32 viewing_range_min = m_cache_viewing_range_min; viewing_range_min = MYMAX(15.0, viewing_range_min); - f32 viewing_range_max = g_settings->getS16("viewing_range_nodes_max"); + f32 viewing_range_max = m_cache_viewing_range_max; viewing_range_max = MYMAX(viewing_range_min, viewing_range_max); // Immediately apply hard limits @@ -542,7 +559,7 @@ void Camera::updateViewingRange(f32 frametime_in, f32 busytime_in) else m_cameranode->setFarValue(viewing_range_max * BS * 10); - f32 wanted_fps = g_settings->getFloat("wanted_fps"); + f32 wanted_fps = m_cache_wanted_fps; wanted_fps = MYMAX(wanted_fps, 1.0); f32 wanted_frametime = 1.0 / wanted_fps; |