summaryrefslogtreecommitdiff
path: root/scene/2d/joints_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/joints_2d.cpp')
-rw-r--r--scene/2d/joints_2d.cpp49
1 files changed, 15 insertions, 34 deletions
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 7d9cdd52ac..8a4ccc2f96 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -66,6 +66,7 @@ void Joint2D::_update_joint(bool p_only_free) {
if (p_only_free || !is_inside_tree()) {
PhysicsServer2D::get_singleton()->joint_clear(joint);
warning = String();
+ update_configuration_warnings();
return;
}
@@ -76,43 +77,26 @@ void Joint2D::_update_joint(bool p_only_free) {
PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
if (node_a && !body_a && node_b && !body_b) {
- PhysicsServer2D::get_singleton()->joint_clear(joint);
warning = TTR("Node A and Node B must be PhysicsBody2Ds");
- update_configuration_warning();
- return;
- }
-
- if (node_a && !body_a) {
- PhysicsServer2D::get_singleton()->joint_clear(joint);
+ } else if (node_a && !body_a) {
warning = TTR("Node A must be a PhysicsBody2D");
- update_configuration_warning();
- return;
- }
-
- if (node_b && !body_b) {
- PhysicsServer2D::get_singleton()->joint_clear(joint);
+ } else if (node_b && !body_b) {
warning = TTR("Node B must be a PhysicsBody2D");
- update_configuration_warning();
- return;
- }
-
- if (!body_a || !body_b) {
- PhysicsServer2D::get_singleton()->joint_clear(joint);
+ } else if (!body_a || !body_b) {
warning = TTR("Joint is not connected to two PhysicsBody2Ds");
- update_configuration_warning();
- return;
+ } else if (body_a == body_b) {
+ warning = TTR("Node A and Node B must be different PhysicsBody2Ds");
+ } else {
+ warning = String();
}
- if (body_a == body_b) {
+ update_configuration_warnings();
+
+ if (!warning.is_empty()) {
PhysicsServer2D::get_singleton()->joint_clear(joint);
- warning = TTR("Node A and Node B must be different PhysicsBody2Ds");
- update_configuration_warning();
return;
}
- warning = String();
- update_configuration_warning();
-
if (body_a) {
body_a->force_update_transform();
}
@@ -211,17 +195,14 @@ bool Joint2D::get_exclude_nodes_from_collision() const {
return exclude_from_collision;
}
-String Joint2D::get_configuration_warning() const {
- String node_warning = Node2D::get_configuration_warning();
+TypedArray<String> Joint2D::get_configuration_warnings() const {
+ TypedArray<String> warnings = Node2D::get_configuration_warnings();
if (!warning.is_empty()) {
- if (!node_warning.is_empty()) {
- node_warning += "\n\n";
- }
- node_warning += warning;
+ warnings.push_back(warning);
}
- return node_warning;
+ return warnings;
}
void Joint2D::_bind_methods() {