mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Make the GameGlobalShaderConstantSetter use the settings callback (8% perf improvement in game loop)
Amend the settings callback to support userdata
This commit is contained in:
parent
aafbbcd537
commit
a555e2d9b0
4 changed files with 27 additions and 11 deletions
|
@ -32,7 +32,7 @@ class Settings;
|
|||
struct NoiseParams;
|
||||
|
||||
/** function type to register a changed callback */
|
||||
typedef void (*setting_changed_callback)(const std::string);
|
||||
typedef void (*setting_changed_callback)(const std::string, void *userdata);
|
||||
|
||||
enum ValueType {
|
||||
VALUETYPE_STRING,
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
void clear();
|
||||
void updateValue(const Settings &other, const std::string &name);
|
||||
void update(const Settings &other);
|
||||
void registerChangedCallback(std::string name, setting_changed_callback cbf);
|
||||
void registerChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -215,7 +215,7 @@ private:
|
|||
|
||||
std::map<std::string, SettingsEntry> m_settings;
|
||||
std::map<std::string, SettingsEntry> m_defaults;
|
||||
std::map<std::string, std::vector<setting_changed_callback> > m_callbacks;
|
||||
std::map<std::string, std::vector<std::pair<setting_changed_callback,void*> > > m_callbacks;
|
||||
// All methods that access m_settings/m_defaults directly should lock this.
|
||||
mutable JMutex m_mutex;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue