mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Only show relevant properties in the DirectionalLight3D inspector
Some split distance properties are unused depending on the current shadow mode. Also, Blend Splits can only be used if the shadow mode is PSSM 2 Splits or PSSM 4 Splits. This also moves the Fade Start property to be located after the split properties. This avoids intertwining "conditional" properties with a property that's always available.
This commit is contained in:
@@ -200,19 +200,8 @@ void Light3D::_validate_property(PropertyInfo &property) const {
|
||||
property.usage = PROPERTY_USAGE_NOEDITOR;
|
||||
}
|
||||
|
||||
if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_size") {
|
||||
property.usage = PROPERTY_USAGE_NONE;
|
||||
}
|
||||
|
||||
if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_specular") {
|
||||
property.usage = PROPERTY_USAGE_NONE;
|
||||
}
|
||||
|
||||
if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_projector") {
|
||||
property.usage = PROPERTY_USAGE_NONE;
|
||||
}
|
||||
|
||||
if (get_light_type() != RS::LIGHT_DIRECTIONAL && property.name == "light_angular_distance") {
|
||||
// Angular distance is only used in DirectionalLight3D.
|
||||
property.usage = PROPERTY_USAGE_NONE;
|
||||
}
|
||||
}
|
||||
@@ -361,6 +350,7 @@ Light3D::~Light3D() {
|
||||
void DirectionalLight3D::set_shadow_mode(ShadowMode p_mode) {
|
||||
shadow_mode = p_mode;
|
||||
RS::get_singleton()->light_directional_set_shadow_mode(light, RS::LightDirectionalShadowMode(p_mode));
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
||||
DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const {
|
||||
@@ -370,6 +360,7 @@ DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const {
|
||||
void DirectionalLight3D::set_blend_splits(bool p_enable) {
|
||||
blend_splits = p_enable;
|
||||
RS::get_singleton()->light_directional_set_blend_splits(light, p_enable);
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
||||
bool DirectionalLight3D::is_blend_splits_enabled() const {
|
||||
@@ -385,6 +376,23 @@ bool DirectionalLight3D::is_sky_only() const {
|
||||
return sky_only;
|
||||
}
|
||||
|
||||
void DirectionalLight3D::_validate_property(PropertyInfo &property) const {
|
||||
if (shadow_mode == SHADOW_ORTHOGONAL && (property.name == "directional_shadow_split_1" || property.name == "directional_shadow_blend_splits")) {
|
||||
// Split 2 and split blending are only used with PSSM 2 Splits and PSSM 4 Splits shadow mode.
|
||||
property.usage = PROPERTY_USAGE_NOEDITOR;
|
||||
}
|
||||
|
||||
if ((shadow_mode == SHADOW_ORTHOGONAL || shadow_mode == SHADOW_PARALLEL_2_SPLITS) && (property.name == "directional_shadow_split_2" || property.name == "directional_shadow_split_3")) {
|
||||
// Splits 3 and 4 are only used with PSSM 4 Splits shadow mode.
|
||||
property.usage = PROPERTY_USAGE_NOEDITOR;
|
||||
}
|
||||
|
||||
if (property.name == "light_size" || property.name == "light_projector" || property.name == "light_specular") {
|
||||
// Not implemented in DirectionalLight3D (`light_size` is replaced by `light_angular_distance`).
|
||||
property.usage = PROPERTY_USAGE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void DirectionalLight3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight3D::set_shadow_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight3D::get_shadow_mode);
|
||||
@@ -400,8 +408,8 @@ void DirectionalLight3D::_bind_methods() {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_1", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_1_OFFSET);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_2", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_2_OFFSET);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_fade_start", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_FADE_START);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_fade_start", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_FADE_START);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_max_distance", PROPERTY_HINT_RANGE, "0,8192,0.1,or_greater,exp"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_pancake_size", PROPERTY_HINT_RANGE, "0,1024,0.1,or_greater,exp"), "set_param", "get_param", PARAM_SHADOW_PANCAKE_SIZE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user