diff options
Diffstat (limited to 'servers/physics_3d/godot_collision_object_3d.cpp')
-rw-r--r-- | servers/physics_3d/godot_collision_object_3d.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/servers/physics_3d/godot_collision_object_3d.cpp b/servers/physics_3d/godot_collision_object_3d.cpp index 0d7fcb67f6..283614a43d 100644 --- a/servers/physics_3d/godot_collision_object_3d.cpp +++ b/servers/physics_3d/godot_collision_object_3d.cpp @@ -210,20 +210,21 @@ void GodotCollisionObject3D::_update_shapes_with_motion(const Vector3 &p_motion) } void GodotCollisionObject3D::_set_space(GodotSpace3D *p_space) { - if (space) { - space->remove_object(this); + GodotSpace3D *old_space = space; + space = p_space; + + if (old_space) { + old_space->remove_object(this); for (int i = 0; i < shapes.size(); i++) { Shape &s = shapes.write[i]; if (s.bpid) { - space->get_broadphase()->remove(s.bpid); + old_space->get_broadphase()->remove(s.bpid); s.bpid = 0; } } } - space = p_space; - if (space) { space->add_object(this); _update_shapes(); |