diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-10-07 21:06:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 21:06:06 +0200 |
commit | 9bbed1fe86d69b11ad64e7e39f1626e2308d4dd4 (patch) | |
tree | 87140f707d97fab14e304734a7adc87aebcf2060 | |
parent | f323d25dd3ba2be5ff491d34df2fbcc3b5ab1efc (diff) | |
parent | 70e1a50cd1e64532e8dfe0f430bd5212dbfaf438 (diff) |
Merge pull request #53543 from vnen/joint-waring-release
Joint2D: Use boolean instead of warning string for validity test
-rw-r--r-- | scene/2d/joint_2d.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/2d/joint_2d.cpp b/scene/2d/joint_2d.cpp index 3b371d4a07..8a528151cf 100644 --- a/scene/2d/joint_2d.cpp +++ b/scene/2d/joint_2d.cpp @@ -74,6 +74,8 @@ void Joint2D::_update_joint(bool p_only_free) { PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a); PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b); + bool valid = false; + if (node_a && !body_a && node_b && !body_b) { warning = TTR("Node A and Node B must be PhysicsBody2Ds"); } else if (node_a && !body_a) { @@ -86,11 +88,12 @@ void Joint2D::_update_joint(bool p_only_free) { warning = TTR("Node A and Node B must be different PhysicsBody2Ds"); } else { warning = String(); + valid = true; } update_configuration_warnings(); - if (!warning.is_empty()) { + if (!valid) { PhysicsServer2D::get_singleton()->joint_clear(joint); return; } |