diff options
Diffstat (limited to 'scene/2d/area_2d.cpp')
| -rw-r--r-- | scene/2d/area_2d.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 2c4bf08f34..b1ff94dda4 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -166,6 +166,21 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i bool body_in = p_status == PhysicsServer2D::AREA_BODY_ADDED; ObjectID objid = p_instance; + // Exit early if instance is invalid. + if (objid.is_null()) { + // Emit the appropriate signals. + lock_callback(); + locked = true; + if (body_in) { + emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_body, (Node *)nullptr, p_body_shape, p_area_shape); + } else { + emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_body, (Node *)nullptr, p_body_shape, p_area_shape); + } + locked = false; + unlock_callback(); + return; + } + Object *obj = ObjectDB::get_instance(objid); Node *node = Object::cast_to<Node>(obj); @@ -262,6 +277,21 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i bool area_in = p_status == PhysicsServer2D::AREA_BODY_ADDED; ObjectID objid = p_instance; + // Exit early if instance is invalid. + if (objid.is_null()) { + // Emit the appropriate signals. + lock_callback(); + locked = true; + if (area_in) { + emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_area, (Node *)nullptr, p_area_shape, p_self_shape); + } else { + emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_area, (Node *)nullptr, p_area_shape, p_self_shape); + } + locked = false; + unlock_callback(); + return; + } + Object *obj = ObjectDB::get_instance(objid); Node *node = Object::cast_to<Node>(obj); |
