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:
lawnjelly
2025-04-29 14:48:52 +01:00
parent 8edf97e342
commit f8f350a32a
48 changed files with 110 additions and 77 deletions

View File

@@ -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;
}