summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-03-01 17:48:44 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-03-02 08:24:50 -0700
commit2dc5ff0caa70944645272ad0684d51b45391a11d (patch)
tree976dc60385e50692c44efeed8c9a80ee6e36a16e /scene/3d
parentf01e95eb55b9798becc47a697f83515c737b5bf3 (diff)
Fix Joint2D/Joint3D node path reset on scene switch
When one of the bodies exited the tree, the corresponding node path was reset instead of just resetting the joint from the physics server. That was causing the node path to be reset on scene switch when one of the bodies is under the joint in the scene tree.
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/physics_joint_3d.cpp18
-rw-r--r--scene/3d/physics_joint_3d.h2
2 files changed, 5 insertions, 15 deletions
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp
index 0463bed9d6..d9aaed3713 100644
--- a/scene/3d/physics_joint_3d.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -46,19 +46,9 @@ void Joint3D::_disconnect_signals() {
}
}
-void Joint3D::_body_exit_tree(const ObjectID &p_body_id) {
+void Joint3D::_body_exit_tree() {
_disconnect_signals();
- Object *object = ObjectDB::get_instance(p_body_id);
- PhysicsBody3D *body = Object::cast_to<PhysicsBody3D>(object);
- ERR_FAIL_NULL(body);
- RID body_rid = body->get_rid();
- if (ba == body_rid) {
- a = NodePath();
- }
- if (bb == body_rid) {
- b = NodePath();
- }
- _update_joint();
+ _update_joint(true);
}
void Joint3D::_update_joint(bool p_only_free) {
@@ -133,12 +123,12 @@ void Joint3D::_update_joint(bool p_only_free) {
if (body_a) {
ba = body_a->get_rid();
- body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree), make_binds(body_a->get_instance_id()));
+ body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree));
}
if (body_b) {
bb = body_b->get_rid();
- body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree), make_binds(body_b->get_instance_id()));
+ body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree));
}
PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h
index 8d0a16e432..f624ba602b 100644
--- a/scene/3d/physics_joint_3d.h
+++ b/scene/3d/physics_joint_3d.h
@@ -51,7 +51,7 @@ class Joint3D : public Node3D {
protected:
void _disconnect_signals();
- void _body_exit_tree(const ObjectID &p_body_id);
+ void _body_exit_tree();
void _update_joint(bool p_only_free = false);
void _notification(int p_what);