Update clouds enable_3d_clouds when setting changed

master
est31 2015-07-09 08:07:59 +02:00
parent 13e100e1d8
commit 4ece2b9e32
2 changed files with 22 additions and 6 deletions

View File

@ -30,6 +30,11 @@ class Clouds;
Clouds *g_menuclouds = NULL; Clouds *g_menuclouds = NULL;
irr::scene::ISceneManager *g_menucloudsmgr = NULL; irr::scene::ISceneManager *g_menucloudsmgr = NULL;
static void cloud_3d_setting_changed(const std::string settingname, void *data)
{
((Clouds *)data)->readSettings();
}
Clouds::Clouds( Clouds::Clouds(
scene::ISceneNode* parent, scene::ISceneNode* parent,
scene::ISceneManager* mgr, scene::ISceneManager* mgr,
@ -52,12 +57,10 @@ Clouds::Clouds(
//m_material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; //m_material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_cloud_y = BS * (cloudheight ? cloudheight : m_passed_cloud_y = cloudheight;
g_settings->getS16("cloud_height")); readSettings();
g_settings->registerChangedCallback("enable_3d_clouds",
m_cloud_radius_i = g_settings->getU16("cloud_radius"); &cloud_3d_setting_changed, this);
m_enable_3d = g_settings->getBool("enable_3d_clouds");
m_box = core::aabbox3d<f32>(-BS*1000000,m_cloud_y-BS,-BS*1000000, m_box = core::aabbox3d<f32>(-BS*1000000,m_cloud_y-BS,-BS*1000000,
BS*1000000,m_cloud_y+BS,BS*1000000); BS*1000000,m_cloud_y+BS,BS*1000000);
@ -66,6 +69,8 @@ Clouds::Clouds(
Clouds::~Clouds() Clouds::~Clouds()
{ {
g_settings->deregisterChangedCallback("enable_3d_clouds",
&cloud_3d_setting_changed, this);
} }
void Clouds::OnRegisterSceneNode() void Clouds::OnRegisterSceneNode()
@ -351,3 +356,11 @@ void Clouds::update(v2f camera_p, video::SColorf color)
//dstream<<"m_brightness="<<m_brightness<<std::endl; //dstream<<"m_brightness="<<m_brightness<<std::endl;
} }
void Clouds::readSettings()
{
m_cloud_y = BS * (m_passed_cloud_y ? m_passed_cloud_y :
g_settings->getS16("cloud_height"));
m_cloud_radius_i = g_settings->getU16("cloud_radius");
m_enable_3d = g_settings->getBool("enable_3d_clouds");
}

View File

@ -83,9 +83,12 @@ public:
BS * 1000000, m_cloud_y + BS - BS * camera_offset.Y, BS * 1000000); BS * 1000000, m_cloud_y + BS - BS * camera_offset.Y, BS * 1000000);
} }
void readSettings();
private: private:
video::SMaterial m_material; video::SMaterial m_material;
core::aabbox3d<f32> m_box; core::aabbox3d<f32> m_box;
s16 m_passed_cloud_y;
float m_cloud_y; float m_cloud_y;
u16 m_cloud_radius_i; u16 m_cloud_radius_i;
bool m_enable_3d; bool m_enable_3d;