summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-10-25 00:11:41 +0200
committerGitHub <noreply@github.com>2018-10-25 00:11:41 +0200
commitbf957a414a27372aaee1aec4ae1a532f76614551 (patch)
tree07a6da344af413dfd82ffa1d1522be1da720f310 /scene
parentf0405d4ae110d5f35655fd272fcb0e2ef9b33ef1 (diff)
parentd67c7487f2e27200a19909ed222c700905adc5d7 (diff)
Merge pull request #23083 from Windfisch/pathfollow_configwarn
Add a configuration warning to [Oriented]PathFollow
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/path.cpp39
-rw-r--r--scene/3d/path.h4
2 files changed, 43 insertions, 0 deletions
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index e37efa0e8a..339a434a6e 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -43,6 +43,16 @@ void Path::_curve_changed() {
if (is_inside_tree()) {
emit_signal("curve_changed");
}
+
+ // update the configuration warnings of all children of type OrientedPathFollows
+ if (is_inside_tree()) {
+ for (int i = 0; i < get_child_count(); i++) {
+ OrientedPathFollow *child = Object::cast_to<OrientedPathFollow>(get_child(i));
+ if (child) {
+ child->update_configuration_warning();
+ }
+ }
+ }
}
void Path::set_curve(const Ref<Curve3D> &p_curve) {
@@ -207,6 +217,18 @@ void PathFollow::_validate_property(PropertyInfo &property) const {
}
}
+String PathFollow::get_configuration_warning() const {
+
+ if (!is_visible_in_tree() || !is_inside_tree())
+ return String();
+
+ if (!Object::cast_to<Path>(get_parent())) {
+ return TTR("PathFollow only works when set as a child of a Path node.");
+ }
+
+ return String();
+}
+
void PathFollow::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow::set_offset);
@@ -444,6 +466,23 @@ void OrientedPathFollow::_validate_property(PropertyInfo &property) const {
}
}
+String OrientedPathFollow::get_configuration_warning() const {
+
+ if (!is_visible_in_tree() || !is_inside_tree())
+ return String();
+
+ if (!Object::cast_to<Path>(get_parent())) {
+ return TTR("OrientedPathFollow only works when set as a child of a Path node.");
+ } else {
+ Path *path = Object::cast_to<Path>(get_parent());
+ if (path->get_curve().is_valid() && !path->get_curve()->is_up_vector_enabled()) {
+ return TTR("OrientedPathFollow requires up vectors enabled in its parent Path.");
+ }
+ }
+
+ return String();
+}
+
void OrientedPathFollow::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &OrientedPathFollow::set_offset);
diff --git a/scene/3d/path.h b/scene/3d/path.h
index f73bf17dfe..beb37d9714 100644
--- a/scene/3d/path.h
+++ b/scene/3d/path.h
@@ -106,6 +106,8 @@ public:
void set_cubic_interpolation(bool p_enable);
bool get_cubic_interpolation() const;
+ String get_configuration_warning() const;
+
PathFollow();
};
@@ -151,6 +153,8 @@ public:
void set_cubic_interpolation(bool p_enable);
bool get_cubic_interpolation() const;
+ String get_configuration_warning() const;
+
OrientedPathFollow();
};