diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-10-02 16:41:55 +0100 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-10-02 17:03:09 +0100 |
commit | 2bb042766273a3cd9f32121433125a7dfb0b366e (patch) | |
tree | a6a970ef65d51bc369767f4baee3377afadc5b37 /scene/2d/area_2d.cpp | |
parent | 7879b0a6e52e425350218f956cac83cd854e0067 (diff) |
Remove area or body from map before emitting signals.
Diffstat (limited to 'scene/2d/area_2d.cpp')
-rw-r--r-- | scene/2d/area_2d.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index ebfcb9cad6..d51ee3f9a8 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -180,26 +180,20 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape)); } - bool eraseit = false; - + bool in_tree = E->get().in_tree; if (E->get().rc == 0) { + body_map.erase(E); if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_body_exit_tree)); - if (E->get().in_tree) { + if (in_tree) { emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } } - - eraseit = true; } - if (!node || E->get().in_tree) { + if (!node || in_tree) { emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape); } - - if (eraseit) { - body_map.erase(E); - } } locked = false; @@ -278,26 +272,20 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape)); } - bool eraseit = false; - + bool in_tree = E->get().in_tree; if (E->get().rc == 0) { + area_map.erase(E); if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_area_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_area_exit_tree)); - if (E->get().in_tree) { + if (in_tree) { emit_signal(SceneStringNames::get_singleton()->area_exited, obj); } } - - eraseit = true; } - if (!node || E->get().in_tree) { + if (!node || in_tree) { emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape); } - - if (eraseit) { - area_map.erase(E); - } } locked = false; |