From a969e2e6f17d6810771e9c9c31551d57e5d1efdb Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 17 Mar 2015 00:45:25 -0300 Subject: Area2D can now detect overlap with other areas this should make everything simpler, specially for newcomers to Godot --- scene/2d/area_2d.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'scene/2d/area_2d.h') diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index f770e88a19..bd00f56ae1 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -53,6 +53,7 @@ private: real_t angular_damp; int priority; bool monitoring; + bool monitorable; bool locked; void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape); @@ -84,6 +85,36 @@ private: Map body_map; + + + void _area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape); + + void _area_enter_tree(ObjectID p_id); + void _area_exit_tree(ObjectID p_id); + + struct AreaShapePair { + + int area_shape; + int self_shape; + bool operator<(const AreaShapePair& p_sp) const { + if (area_shape==p_sp.area_shape) + return self_shape < p_sp.self_shape; + else + return area_shape < p_sp.area_shape; + } + + AreaShapePair() {} + AreaShapePair(int p_bs, int p_as) { area_shape=p_bs; self_shape=p_as; } + }; + + struct AreaState { + + int rc; + bool in_tree; + VSet shapes; + }; + + Map area_map; void _clear_monitoring(); @@ -117,7 +148,11 @@ public: void set_enable_monitoring(bool p_enable); bool is_monitoring_enabled() const; + void set_monitorable(bool p_enable); + bool is_monitorable() const; + Array get_overlapping_bodies() const; //function for script + Array get_overlapping_areas() const; //function for script Area2D(); -- cgit v1.2.3 From 4cac1e0cb6406609b915797ca41ad125f9b3da08 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 17 Mar 2015 09:25:35 -0300 Subject: add functions to test overlap with another body or area --- scene/2d/area_2d.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scene/2d/area_2d.h') diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index bd00f56ae1..6a6c757e0c 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -154,6 +154,8 @@ public: Array get_overlapping_bodies() const; //function for script Array get_overlapping_areas() const; //function for script + bool overlaps_area(Node* p_area) const; + bool overlaps_body(Node* p_body) const; Area2D(); ~Area2D(); -- cgit v1.2.3