summaryrefslogtreecommitdiffstats
path: root/scene/3d/area_3d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/area_3d.cpp')
-rw-r--r--scene/3d/area_3d.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp
index 585bce09fb..014c33cad0 100644
--- a/scene/3d/area_3d.cpp
+++ b/scene/3d/area_3d.cpp
@@ -223,6 +223,21 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
bool body_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
+ // Exit early if instance is invalid.
+ if (objid.is_null()) {
+ lock_callback();
+ locked = true;
+ // Emit the appropriate signals.
+ 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);
@@ -254,7 +269,7 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
E->value.shapes.insert(ShapePair(p_body_shape, p_area_shape));
}
- if (E->value.in_tree) {
+ if (!node || E->value.in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_body, node, p_body_shape, p_area_shape);
}
@@ -276,7 +291,7 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
}
}
}
- if (node && in_tree) {
+ if (!node || in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_body, obj, p_body_shape, p_area_shape);
}
}
@@ -414,6 +429,21 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
bool area_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
+ // Exit if instance is invalid.
+ if (objid.is_null()) {
+ lock_callback();
+ locked = true;
+ // Emit the appropriate signals.
+ 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);