summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-07-29 01:39:49 +0200
committerGitHub <noreply@github.com>2021-07-29 01:39:49 +0200
commit48857194b360dabdaac7cd4c9c6714546ca15aa1 (patch)
tree4d5b754d3e6bcc89ed5f42ce0001b2845e588774
parent2ae069a97e208708b0e4bd9a9ac5df3829c9854b (diff)
parent48fc5b2480dc394feae9cd7c4ec62cf8740cddbc (diff)
Merge pull request #50981 from Calinou/geometryinstance3d-distance-add-configuration-warnings
Add node configuration warning for GeometryInstance3D distance
-rw-r--r--scene/3d/visual_instance_3d.cpp12
-rw-r--r--scene/3d/visual_instance_3d.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp
index 70a7021f22..c155819159 100644
--- a/scene/3d/visual_instance_3d.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -153,6 +153,7 @@ Ref<Material> GeometryInstance3D::get_material_override() const {
void GeometryInstance3D::set_visibility_range_begin(float p_dist) {
visibility_range_begin = p_dist;
RS::get_singleton()->instance_geometry_set_visibility_range(get_instance(), visibility_range_begin, visibility_range_end, visibility_range_begin_margin, visibility_range_end_margin);
+ update_configuration_warnings();
}
float GeometryInstance3D::get_visibility_range_begin() const {
@@ -162,6 +163,7 @@ float GeometryInstance3D::get_visibility_range_begin() const {
void GeometryInstance3D::set_visibility_range_end(float p_dist) {
visibility_range_end = p_dist;
RS::get_singleton()->instance_geometry_set_visibility_range(get_instance(), visibility_range_begin, visibility_range_end, visibility_range_begin_margin, visibility_range_end_margin);
+ update_configuration_warnings();
}
float GeometryInstance3D::get_visibility_range_end() const {
@@ -351,6 +353,16 @@ bool GeometryInstance3D::is_ignoring_occlusion_culling() {
return ignore_occlusion_culling;
}
+TypedArray<String> GeometryInstance3D::get_configuration_warnings() const {
+ TypedArray<String> warnings = Node::get_configuration_warnings();
+
+ if (!Math::is_zero_approx(visibility_range_end) && visibility_range_end <= visibility_range_begin) {
+ warnings.push_back(TTR("The GeometryInstance3D visibility range's End distance is set to a non-zero value, but is lower than the Begin distance.\nThis means the GeometryInstance3D will never be visible.\nTo resolve this, set the End distance to 0 or to a value greater than the Begin distance."));
+ }
+
+ return warnings;
+}
+
void GeometryInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override);
ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override);
diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h
index 2d5699859b..97aac149a1 100644
--- a/scene/3d/visual_instance_3d.h
+++ b/scene/3d/visual_instance_3d.h
@@ -177,6 +177,7 @@ public:
void set_ignore_occlusion_culling(bool p_enabled);
bool is_ignoring_occlusion_culling();
+ TypedArray<String> get_configuration_warnings() const override;
GeometryInstance3D();
};