Add a configuration warning when using ultrawide SpotLight with shadows

This partially addresses #12028.
This commit is contained in:
Hugo Locurcio 2019-07-07 16:22:09 +02:00
parent 1fa26b969c
commit cdd41d446f
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
2 changed files with 21 additions and 0 deletions

View file

@ -51,6 +51,7 @@ void Light::set_param(Param p_param, float p_value) {
if (p_param == PARAM_SPOT_ANGLE) { if (p_param == PARAM_SPOT_ANGLE) {
_change_notify("spot_angle"); _change_notify("spot_angle");
update_configuration_warning();
} else if (p_param == PARAM_RANGE) { } else if (p_param == PARAM_RANGE) {
_change_notify("omni_range"); _change_notify("omni_range");
_change_notify("spot_range"); _change_notify("spot_range");
@ -68,6 +69,10 @@ void Light::set_shadow(bool p_enable) {
shadow = p_enable; shadow = p_enable;
VS::get_singleton()->light_set_shadow(light, p_enable); VS::get_singleton()->light_set_shadow(light, p_enable);
if (type == VisualServer::LIGHT_SPOT) {
update_configuration_warning();
}
} }
bool Light::has_shadow() const { bool Light::has_shadow() const {
@ -465,6 +470,20 @@ OmniLight::OmniLight() :
set_shadow_detail(SHADOW_DETAIL_HORIZONTAL); 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() { void SpotLight::_bind_methods() {
ADD_GROUP("Spot", "spot_"); ADD_GROUP("Spot", "spot_");

View file

@ -221,6 +221,8 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
virtual String get_configuration_warning() const;
SpotLight() : SpotLight() :
Light(VisualServer::LIGHT_SPOT) {} Light(VisualServer::LIGHT_SPOT) {}
}; };