Merge pull request #53543 from vnen/joint-waring-release

Joint2D: Use boolean instead of warning string for validity test
This commit is contained in:
Rémi Verschelde 2021-10-07 21:06:06 +02:00 committed by GitHub
commit 9bbed1fe86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -74,6 +74,8 @@ void Joint2D::_update_joint(bool p_only_free) {
PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a); PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b); PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
bool valid = false;
if (node_a && !body_a && node_b && !body_b) { if (node_a && !body_a && node_b && !body_b) {
warning = TTR("Node A and Node B must be PhysicsBody2Ds"); warning = TTR("Node A and Node B must be PhysicsBody2Ds");
} else if (node_a && !body_a) { } 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"); warning = TTR("Node A and Node B must be different PhysicsBody2Ds");
} else { } else {
warning = String(); warning = String();
valid = true;
} }
update_configuration_warnings(); update_configuration_warnings();
if (!warning.is_empty()) { if (!valid) {
PhysicsServer2D::get_singleton()->joint_clear(joint); PhysicsServer2D::get_singleton()->joint_clear(joint);
return; return;
} }