Implement Area.has_overlapping_*
This commit is contained in:
parent
24ce46e2a1
commit
ed4fe1e2bd
|
@ -25,10 +25,24 @@
|
|||
<method name="get_overlapping_bodies" qualifiers="const">
|
||||
<return type="Node2D[]" />
|
||||
<description>
|
||||
Returns a list of intersecting [PhysicsBody2D]s. The overlapping body's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
|
||||
Returns a list of intersecting [PhysicsBody2D]s and [TileMap]s. The overlapping body's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
|
||||
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_overlapping_areas" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if intersecting any [Area2D]s, otherwise returns [code]false[/code]. The overlapping area's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
|
||||
For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_overlapping_bodies" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if intersecting any [PhysicsBody2D]s or [TileMap]s, otherwise returns [code]false[/code]. The overlapping body's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
|
||||
For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="overlaps_area" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="area" type="Node" />
|
||||
|
|
|
@ -23,10 +23,24 @@
|
|||
<method name="get_overlapping_bodies" qualifiers="const">
|
||||
<return type="Node3D[]" />
|
||||
<description>
|
||||
Returns a list of intersecting [PhysicsBody3D]s. The overlapping body's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
|
||||
Returns a list of intersecting [PhysicsBody3D]s and [GridMap]s. The overlapping body's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
|
||||
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_overlapping_areas" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if intersecting any [Area3D]s, otherwise returns [code]false[/code]. The overlapping area's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
|
||||
For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_overlapping_bodies" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if intersecting any [PhysicsBody3D]s or [GridMap]s, otherwise returns [code]false[/code]. The overlapping body's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
|
||||
For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="overlaps_area" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="area" type="Node" />
|
||||
|
|
|
@ -459,6 +459,16 @@ TypedArray<Area2D> Area2D::get_overlapping_areas() const {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Area2D::has_overlapping_bodies() const {
|
||||
ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping bodies when monitoring is off.");
|
||||
return !body_map.is_empty();
|
||||
}
|
||||
|
||||
bool Area2D::has_overlapping_areas() const {
|
||||
ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping areas when monitoring is off.");
|
||||
return !area_map.is_empty();
|
||||
}
|
||||
|
||||
bool Area2D::overlaps_area(Node *p_area) const {
|
||||
ERR_FAIL_NULL_V(p_area, false);
|
||||
HashMap<ObjectID, AreaState>::ConstIterator E = area_map.find(p_area->get_instance_id());
|
||||
|
@ -578,6 +588,9 @@ void Area2D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area2D::get_overlapping_bodies);
|
||||
ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area2D::get_overlapping_areas);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_overlapping_bodies"), &Area2D::has_overlapping_bodies);
|
||||
ClassDB::bind_method(D_METHOD("has_overlapping_areas"), &Area2D::has_overlapping_areas);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area2D::overlaps_body);
|
||||
ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area2D::overlaps_area);
|
||||
|
||||
|
|
|
@ -180,6 +180,9 @@ public:
|
|||
TypedArray<Node2D> get_overlapping_bodies() const; //function for script
|
||||
TypedArray<Area2D> get_overlapping_areas() const; //function for script
|
||||
|
||||
bool has_overlapping_bodies() const;
|
||||
bool has_overlapping_areas() const;
|
||||
|
||||
bool overlaps_area(Node *p_area) const;
|
||||
bool overlaps_body(Node *p_body) const;
|
||||
|
||||
|
|
|
@ -489,6 +489,11 @@ TypedArray<Node3D> Area3D::get_overlapping_bodies() const {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Area3D::has_overlapping_bodies() const {
|
||||
ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping bodies when monitoring is off.");
|
||||
return !body_map.is_empty();
|
||||
}
|
||||
|
||||
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).");
|
||||
|
||||
|
@ -521,6 +526,11 @@ TypedArray<Area3D> Area3D::get_overlapping_areas() const {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Area3D::has_overlapping_areas() const {
|
||||
ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping areas when monitoring is off.");
|
||||
return !area_map.is_empty();
|
||||
}
|
||||
|
||||
bool Area3D::overlaps_area(Node *p_area) const {
|
||||
ERR_FAIL_NULL_V(p_area, false);
|
||||
HashMap<ObjectID, AreaState>::ConstIterator E = area_map.find(p_area->get_instance_id());
|
||||
|
@ -686,6 +696,9 @@ void Area3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area3D::get_overlapping_bodies);
|
||||
ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area3D::get_overlapping_areas);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_overlapping_bodies"), &Area3D::has_overlapping_bodies);
|
||||
ClassDB::bind_method(D_METHOD("has_overlapping_areas"), &Area3D::has_overlapping_areas);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area3D::overlaps_body);
|
||||
ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area3D::overlaps_area);
|
||||
|
||||
|
|
|
@ -201,6 +201,9 @@ public:
|
|||
TypedArray<Node3D> get_overlapping_bodies() const;
|
||||
TypedArray<Area3D> get_overlapping_areas() const; //function for script
|
||||
|
||||
bool has_overlapping_bodies() const;
|
||||
bool has_overlapping_areas() const;
|
||||
|
||||
bool overlaps_area(Node *p_area) const;
|
||||
bool overlaps_body(Node *p_body) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue