summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-08-24 17:10:54 +0200
committerGitHub <noreply@github.com>2018-08-24 17:10:54 +0200
commit77185aaf21f6235dd7aab664d191e149390ad5ee (patch)
tree1ff00591675f4183d7414d1bd5d28d5c37fc74ba /scene
parent0b67d1665d94f91069e9163087f51c632d5b4d1d (diff)
parentb5480634c36bcc2375b1f0fc8fa58b5a5cc357c0 (diff)
Merge pull request #21049 from AndreaCatania/joints
Improved 6DOF joint implementation
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/physics_joint.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index 7988c43eab..a30fc0ac3e 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -48,18 +48,14 @@ void Joint::_update_joint(bool p_only_free) {
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
- if (!node_a || !node_b)
- return;
-
PhysicsBody *body_a = Object::cast_to<PhysicsBody>(node_a);
PhysicsBody *body_b = Object::cast_to<PhysicsBody>(node_b);
- if (!body_a || !body_b)
- return;
-
- if (!body_a) {
+ if (!body_a && body_b)
SWAP(body_a, body_b);
- }
+
+ if (!body_a)
+ return;
joint = _configure_joint(body_a, body_b);
@@ -69,7 +65,8 @@ void Joint::_update_joint(bool p_only_free) {
PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
ba = body_a->get_rid();
- bb = body_b->get_rid();
+ if (body_b)
+ bb = body_b->get_rid();
PhysicsServer::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
}