diff options
Diffstat (limited to 'scene/3d/area_3d.cpp')
-rw-r--r-- | scene/3d/area_3d.cpp | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index 3b5b6c0dd6..a024757927 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -165,8 +165,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } } E->get().rc++; - if (node) + if (node) { E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape)); + } if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape); @@ -175,8 +176,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } else { E->get().rc--; - if (node) + if (node) { E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape)); + } bool eraseit = false; @@ -184,8 +186,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree)); - if (E->get().in_tree) + if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_exited, obj); + } } eraseit = true; @@ -194,8 +197,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape); } - if (eraseit) + if (eraseit) { body_map.erase(E); + } } locked = false; @@ -213,12 +217,14 @@ void Area3D::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to<Node>(obj); - if (!node) //node may have been deleted in previous frame or at other legiminate point + if (!node) { //node may have been deleted in previous frame or at other legiminate point continue; + } //ERR_CONTINUE(!node); - if (!E->get().in_tree) + if (!E->get().in_tree) { continue; + } for (int i = 0; i < E->get().shapes.size(); i++) { emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape); @@ -240,12 +246,14 @@ void Area3D::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = Object::cast_to<Node>(obj); - if (!node) //node may have been deleted in previous frame or at other legiminate point + if (!node) { //node may have been deleted in previous frame or at other legiminate point continue; + } //ERR_CONTINUE(!node); - if (!E->get().in_tree) + if (!E->get().in_tree) { continue; + } for (int i = 0; i < E->get().shapes.size(); i++) { emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape); @@ -268,8 +276,9 @@ void Area3D::_notification(int p_what) { void Area3D::set_monitoring(bool p_enable) { ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false)."); - if (p_enable == monitoring) + if (p_enable == monitoring) { return; + } monitoring = p_enable; @@ -342,8 +351,9 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } } E->get().rc++; - if (node) + if (node) { E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape)); + } if (!node || E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape); @@ -352,8 +362,9 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } else { E->get().rc--; - if (node) + if (node) { E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape)); + } bool eraseit = false; @@ -372,8 +383,9 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape); } - if (eraseit) + if (eraseit) { area_map.erase(E); + } } locked = false; @@ -403,8 +415,9 @@ TypedArray<Node3D> Area3D::get_overlapping_bodies() const { void Area3D::set_monitorable(bool p_enable) { ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); - if (p_enable == monitorable) + if (p_enable == monitorable) { return; + } monitorable = p_enable; @@ -435,16 +448,18 @@ TypedArray<Area3D> Area3D::get_overlapping_areas() const { bool Area3D::overlaps_area(Node *p_area) const { ERR_FAIL_NULL_V(p_area, false); const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id()); - if (!E) + if (!E) { return false; + } return E->get().in_tree; } bool Area3D::overlaps_body(Node *p_body) const { ERR_FAIL_NULL_V(p_body, false); const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id()); - if (!E) + if (!E) { return false; + } return E->get().in_tree; } @@ -468,10 +483,11 @@ uint32_t Area3D::get_collision_layer() const { void Area3D::set_collision_mask_bit(int p_bit, bool p_value) { uint32_t mask = get_collision_mask(); - if (p_value) + if (p_value) { mask |= 1 << p_bit; - else + } else { mask &= ~(1 << p_bit); + } set_collision_mask(mask); } @@ -481,10 +497,11 @@ bool Area3D::get_collision_mask_bit(int p_bit) const { void Area3D::set_collision_layer_bit(int p_bit, bool p_value) { uint32_t layer = get_collision_layer(); - if (p_value) + if (p_value) { layer |= 1 << p_bit; - else + } else { layer &= ~(1 << p_bit); + } set_collision_layer(layer); } @@ -554,8 +571,9 @@ void Area3D::_validate_property(PropertyInfo &property) const { if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") { String options; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { - if (i > 0) + if (i > 0) { options += ","; + } String name = AudioServer::get_singleton()->get_bus_name(i); options += name; } |