mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 06:32:23 +01:00
Fix re-loading of settings in ClientMap
This commit is contained in:
parent
c52a4369eb
commit
c00fed20b7
@ -73,11 +73,23 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
ClientMap
|
||||||
|
*/
|
||||||
|
|
||||||
static void on_settings_changed(const std::string &name, void *data)
|
static void on_settings_changed(const std::string &name, void *data)
|
||||||
{
|
{
|
||||||
static_cast<ClientMap*>(data)->onSettingChanged(name);
|
static_cast<ClientMap*>(data)->onSettingChanged(name, false);
|
||||||
}
|
}
|
||||||
// ClientMap
|
|
||||||
|
static const std::string ClientMap_settings[] = {
|
||||||
|
"trilinear_filter",
|
||||||
|
"bilinear_filter",
|
||||||
|
"anisotropic_filter",
|
||||||
|
"transparency_sorting_distance",
|
||||||
|
"occlusion_culler",
|
||||||
|
"enable_raytraced_culling",
|
||||||
|
};
|
||||||
|
|
||||||
ClientMap::ClientMap(
|
ClientMap::ClientMap(
|
||||||
Client *client,
|
Client *client,
|
||||||
@ -102,37 +114,32 @@ ClientMap::ClientMap(
|
|||||||
m_box = aabb3f(-BS*1000000,-BS*1000000,-BS*1000000,
|
m_box = aabb3f(-BS*1000000,-BS*1000000,-BS*1000000,
|
||||||
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
|
for (const auto &name : ClientMap_settings)
|
||||||
* changes. At this point in time it doesn't matter (e.g. /set
|
g_settings->registerChangedCallback(name, on_settings_changed, this);
|
||||||
* is documented to change server settings only)
|
// load all settings at once
|
||||||
*
|
onSettingChanged("", true);
|
||||||
* 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");
|
|
||||||
m_cache_transparency_sorting_distance = g_settings->getU16("transparency_sorting_distance");
|
|
||||||
m_loops_occlusion_culler = g_settings->get("occlusion_culler") == "loops";
|
|
||||||
g_settings->registerChangedCallback("occlusion_culler", on_settings_changed, this);
|
|
||||||
m_enable_raytraced_culling = g_settings->getBool("enable_raytraced_culling");
|
|
||||||
g_settings->registerChangedCallback("enable_raytraced_culling", on_settings_changed, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientMap::onSettingChanged(const std::string &name)
|
void ClientMap::onSettingChanged(std::string_view name, bool all)
|
||||||
{
|
{
|
||||||
if (name == "occlusion_culler")
|
if (all || name == "trilinear_filter")
|
||||||
|
m_cache_trilinear_filter = g_settings->getBool("trilinear_filter");
|
||||||
|
if (all || name == "bilinear_filter")
|
||||||
|
m_cache_bilinear_filter = g_settings->getBool("bilinear_filter");
|
||||||
|
if (all || name == "anisotropic_filter")
|
||||||
|
m_cache_anistropic_filter = g_settings->getBool("anisotropic_filter");
|
||||||
|
if (all || name == "transparency_sorting_distance")
|
||||||
|
m_cache_transparency_sorting_distance = g_settings->getU16("transparency_sorting_distance");
|
||||||
|
if (all || name == "occlusion_culler")
|
||||||
m_loops_occlusion_culler = g_settings->get("occlusion_culler") == "loops";
|
m_loops_occlusion_culler = g_settings->get("occlusion_culler") == "loops";
|
||||||
if (name == "enable_raytraced_culling")
|
if (all || name == "enable_raytraced_culling")
|
||||||
m_enable_raytraced_culling = g_settings->getBool("enable_raytraced_culling");
|
m_enable_raytraced_culling = g_settings->getBool("enable_raytraced_culling");
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientMap::~ClientMap()
|
ClientMap::~ClientMap()
|
||||||
{
|
{
|
||||||
g_settings->deregisterChangedCallback("occlusion_culler", on_settings_changed, this);
|
for (const auto &name : ClientMap_settings)
|
||||||
g_settings->deregisterChangedCallback("enable_raytraced_culling", on_settings_changed, this);
|
g_settings->deregisterChangedCallback(name, on_settings_changed, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientMap::updateCamera(v3f pos, v3f dir, f32 fov, v3s16 offset, video::SColor light_color)
|
void ClientMap::updateCamera(v3f pos, v3f dir, f32 fov, v3s16 offset, video::SColor light_color)
|
||||||
|
@ -112,7 +112,7 @@ public:
|
|||||||
f32 getWantedRange() const { return m_control.wanted_range; }
|
f32 getWantedRange() const { return m_control.wanted_range; }
|
||||||
f32 getCameraFov() const { return m_camera_fov; }
|
f32 getCameraFov() const { return m_camera_fov; }
|
||||||
|
|
||||||
void onSettingChanged(const std::string &name);
|
void onSettingChanged(std::string_view name, bool all);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// use drop() instead
|
// use drop() instead
|
||||||
|
Loading…
Reference in New Issue
Block a user