mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Add GLOBAL_GET cached macros.
GLOBAL_GET is an expensive operation which should not be used each frame / tick. This PR adds macros which do a cheaper revision check, and only call the expensive GLOBAL_GET when project settings have changed. Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com>
This commit is contained in:
@@ -112,7 +112,7 @@ float Environment::get_bg_intensity() const {
|
||||
}
|
||||
|
||||
void Environment::_update_bg_energy() {
|
||||
if (GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
|
||||
if (GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units")) {
|
||||
RS::get_singleton()->environment_set_bg_energy(environment, bg_energy_multiplier, bg_intensity);
|
||||
} else {
|
||||
RS::get_singleton()->environment_set_bg_energy(environment, bg_energy_multiplier, 1.0);
|
||||
@@ -1158,7 +1158,7 @@ void Environment::_validate_property(PropertyInfo &p_property) const {
|
||||
}
|
||||
}
|
||||
|
||||
if (p_property.name == "background_intensity" && !GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
|
||||
if (p_property.name == "background_intensity" && !GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units")) {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user