NOTE 1: This does not mean a 2x increase in framerate. Increase in fps may be up to 1-2fps
NOTE 2: This local 'caching' of settings is not optimal and an alternative solution will be worked on after 0.4.11 is released
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()
// 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
//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;
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);
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")))
{
<<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
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;
ItemStack m_wield_item_next;
CameraMode m_camera_mode;
+
+ f32 m_cache_fall_bobbing_amount;
+ f32 m_cache_view_bobbing_amount;
+ f32 m_cache_viewing_range_min;
+ f32 m_cache_viewing_range_max;
+ f32 m_cache_wanted_fps;
+ f32 m_cache_fov;
+ bool m_cache_view_bobbing;
};
#endif
} else {
localdb = NULL;
}
+
+ m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
}
void Client::Stop()
data->fill(b);
data->setCrack(m_crack_level, m_crack_pos);
data->setHighlighted(m_highlighted_pos, m_show_highlighted);
- data->setSmoothLighting(g_settings->getBool("smooth_lighting"));
+ data->setSmoothLighting(m_cache_smooth_lighting);
}
// Add task to queue
// Used for saving server map to disk client-side
Database *localdb;
Server *localserver;
+
+ // TODO: Add callback to update this when g_settings changes
+ bool m_cache_smooth_lighting;
};
#endif // !CLIENT_HEADER
{
m_box = core::aabbox3d<f32>(-BS*1000000,-BS*1000000,-BS*1000000,
BS*1000000,BS*1000000,BS*1000000);
+
+ /* 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_trilinear_filter = g_settings->getBool("trilinear_filter");
+ m_cache_bilinear_filter = g_settings->getBool("bilinear_filter");
+ m_cache_anistropic_filter = g_settings->getBool("anisotropic_filter");
+
}
ClientMap::~ClientMap()
m_last_drawn_sectors.clear();
}
- bool use_trilinear_filter = g_settings->getBool("trilinear_filter");
- bool use_bilinear_filter = g_settings->getBool("bilinear_filter");
- bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
-
/*
Get time for measuring timeout.
{
scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
- buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
- buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
- buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
+ buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
+ buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
const video::SMaterial& material = buf->getMaterial();
video::IMaterialRenderer* rnd =
std::map<v3s16, MapBlock*> m_drawlist;
std::set<v2s16> m_last_drawn_sectors;
+
+ bool m_cache_trilinear_filter;
+ bool m_cache_bilinear_filter;
+ bool m_cache_anistropic_filter;
};
#endif
m_enable_day_night_ratio_override(false),
m_day_night_ratio_override(0.0f)
{
+ m_cache_enable_shaders = g_settings->getBool("enable_shaders");
}
Environment::~Environment()
{
if(m_enable_day_night_ratio_override)
return m_day_night_ratio_override;
- bool smooth = g_settings->getBool("enable_shaders");
- return time_to_daynight_ratio(m_time_of_day_f*24000, smooth);
+ return time_to_daynight_ratio(m_time_of_day_f*24000, m_cache_enable_shaders);
}
void Environment::setTimeOfDaySpeed(float speed)
// Overriding the day-night ratio is useful for custom sky visuals
bool m_enable_day_night_ratio_override;
u32 m_day_night_ratio_override;
+
+ /* 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.
+ */
+ bool m_cache_enable_shaders;
private:
JMutex m_lock;
KeyCache keycache;
IntervalLimiter profiler_interval;
+
+ /* 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.
+ */
+ bool m_cache_doubletap_jump;
+ bool m_cache_enable_node_highlighting;
+ bool m_cache_enable_clouds;
+ bool m_cache_enable_particles;
+ bool m_cache_enable_fog;
+ f32 m_cache_mouse_sensitivity;
+ f32 m_repeat_right_click_time;
};
Game::Game() :
local_inventory(NULL),
hud(NULL)
{
-
+ m_cache_doubletap_jump = g_settings->getBool("doubletap_jump");
+ m_cache_enable_node_highlighting = g_settings->getBool("enable_node_highlighting");
+ m_cache_enable_clouds = g_settings->getBool("enable_clouds");
+ m_cache_enable_particles = g_settings->getBool("enable_particles");
+ m_cache_enable_fog = g_settings->getBool("enable_fog");
+ m_cache_mouse_sensitivity = g_settings->getFloat("mouse_sensitivity");
+ m_repeat_right_click_time = g_settings->getFloat("repeat_rightclick_time");
}
/* Clouds
*/
- if (g_settings->getBool("enable_clouds")) {
+ if (m_cache_enable_clouds) {
clouds = new Clouds(smgr->getRootSceneNode(), smgr, -1, time(0));
if (!clouds) {
*error_message = L"Memory allocation error";
#endif
// Increase timer for double tap of "keymap_jump"
- if (g_settings->getBool("doubletap_jump") && interact_args->jump_timer <= 0.2)
+ if (m_cache_doubletap_jump && interact_args->jump_timer <= 0.2)
interact_args->jump_timer += dtime;
processKeyboardInput(
void Game::toggleFreeMoveAlt(float *statustext_time, float *jump_timer)
{
- if (g_settings->getBool("doubletap_jump") && *jump_timer < 0.2f)
+ if (m_cache_doubletap_jump && *jump_timer < 0.2f)
toggleFreeMove(statustext_time);
}
//infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
- float d = g_settings->getFloat("mouse_sensitivity");
+ float d = m_cache_mouse_sensitivity;
d = rangelim(d, 0.01, 100.0);
cam->camera_yaw -= dx * d;
cam->camera_pitch += dy * d;
if (pointed != runData->pointed_old) {
infostream << "Pointing at " << pointed.dump() << std::endl;
- if (g_settings->getBool("enable_node_highlighting")) {
+ if (m_cache_enable_node_highlighting) {
if (pointed.type == POINTEDTHING_NODE) {
client->setHighlighted(pointed.node_undersurface, show_hud);
} else {
}
if ((input->getRightClicked() ||
- runData->repeat_rightclick_timer >=
- g_settings->getFloat("repeat_rightclick_time")) &&
+ runData->repeat_rightclick_timer >= m_repeat_right_click_time) &&
client->checkPrivilege("interact")) {
runData->repeat_rightclick_timer = 0;
infostream << "Ground right-clicked" << std::endl;
} else {
runData->dig_time_complete = params.time;
- if (g_settings->getBool("enable_particles")) {
+ if (m_cache_enable_particles) {
const ContentFeatures &features =
client->getNodeDefManager()->get(n);
addPunchingParticles(gamedef, smgr, player,
if (is_valid_position)
client->removeNode(nodepos);
- if (g_settings->getBool("enable_particles")) {
+ if (m_cache_enable_particles) {
const ContentFeatures &features =
client->getNodeDefManager()->get(wasnode);
addDiggingParticles
Fog
*/
- if (g_settings->getBool("enable_fog") && !flags.force_fog_off) {
+ if (m_cache_enable_fog && !flags.force_fog_off) {
driver->setFog(
sky->getBgColor(),
video::EFT_FOG_LINEAR,