mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02: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:
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)
|
||||
|
Reference in New Issue
Block a user