diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-09 08:28:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-09 08:28:47 +0200 |
commit | 675b9cb4c2e9b496005216c13d5f19eee892a4f5 (patch) | |
tree | 3c4ee6f842934d420ff5382aba0a8f1a1cf30517 /scene/3d | |
parent | c2cf640753cbf0b4a74c5dba8a6ae815e2923331 (diff) | |
parent | cdd41d446fde4d4ef5be74986110724427ad6f2f (diff) |
Merge pull request #30404 from Calinou/add-spotlight-configuration-warning
Add a configuration warning when using ultrawide SpotLight with shadows
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/light.cpp | 19 | ||||
-rw-r--r-- | scene/3d/light.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 2e64872616..4ef945ab8d 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -51,6 +51,7 @@ void Light::set_param(Param p_param, float p_value) { if (p_param == PARAM_SPOT_ANGLE) { _change_notify("spot_angle"); + update_configuration_warning(); } else if (p_param == PARAM_RANGE) { _change_notify("omni_range"); _change_notify("spot_range"); @@ -68,6 +69,10 @@ void Light::set_shadow(bool p_enable) { shadow = p_enable; VS::get_singleton()->light_set_shadow(light, p_enable); + + if (type == VisualServer::LIGHT_SPOT) { + update_configuration_warning(); + } } bool Light::has_shadow() const { @@ -465,6 +470,20 @@ OmniLight::OmniLight() : set_shadow_detail(SHADOW_DETAIL_HORIZONTAL); } +String SpotLight::get_configuration_warning() const { + String warning = Light::get_configuration_warning(); + + if (has_shadow() && get_param(PARAM_SPOT_ANGLE) >= 90.0) { + if (warning != String()) { + warning += "\n\n"; + } + + warning += TTR("A SpotLight with an angle wider than 90 degrees cannot cast shadows."); + } + + return warning; +} + void SpotLight::_bind_methods() { ADD_GROUP("Spot", "spot_"); diff --git a/scene/3d/light.h b/scene/3d/light.h index ddd5bc6b3a..5d365758b5 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -221,6 +221,8 @@ protected: static void _bind_methods(); public: + virtual String get_configuration_warning() const; + SpotLight() : Light(VisualServer::LIGHT_SPOT) {} }; |