mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Settings fixes Make the GameGlobalShaderConstantSetter use the settings callback (8% perf improvement in game loop) Ensure variable is set Ensure settings callback is threadsafe
This commit is contained in:
parent
2c4a5e1861
commit
ed7c9c4cb8
4 changed files with 67 additions and 33 deletions
23
src/game.cpp
23
src/game.cpp
|
@ -809,16 +809,35 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||
bool *m_force_fog_off;
|
||||
f32 *m_fog_range;
|
||||
Client *m_client;
|
||||
bool m_fogEnabled;
|
||||
|
||||
public:
|
||||
void onSettingsChange(const std::string &name)
|
||||
{
|
||||
if (name == "enable_fog")
|
||||
m_fogEnabled = g_settings->getBool("enable_fog");
|
||||
}
|
||||
|
||||
static void SettingsCallback(const std::string name, void *userdata)
|
||||
{
|
||||
reinterpret_cast<GameGlobalShaderConstantSetter*>(userdata)->onSettingsChange(name);
|
||||
}
|
||||
|
||||
GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
|
||||
f32 *fog_range, Client *client) :
|
||||
m_sky(sky),
|
||||
m_force_fog_off(force_fog_off),
|
||||
m_fog_range(fog_range),
|
||||
m_client(client)
|
||||
{}
|
||||
~GameGlobalShaderConstantSetter() {}
|
||||
{
|
||||
g_settings->registerChangedCallback("enable_fog", SettingsCallback, this);
|
||||
m_fogEnabled = g_settings->getBool("enable_fog");
|
||||
}
|
||||
|
||||
~GameGlobalShaderConstantSetter()
|
||||
{
|
||||
g_settings->deregisterChangedCallback("enable_fog", SettingsCallback, this);
|
||||
}
|
||||
|
||||
virtual void onSetConstants(video::IMaterialRendererServices *services,
|
||||
bool is_highlevel)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue