diff options
| author | Juan Linietsky | 2015-03-17 00:45:25 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2015-03-17 00:45:25 -0300 |
| commit | a969e2e6f17d6810771e9c9c31551d57e5d1efdb (patch) | |
| tree | 1a1e2b6ca26bd99015856ce886cdf92f1d0b84d6 /servers/physics_2d/space_2d_sw.cpp | |
| parent | 53e1694e1e2b76026d862e84c1de88f62601cbc3 (diff) | |
| download | godot-a969e2e6f17d6810771e9c9c31551d57e5d1efdb.tar.gz godot-a969e2e6f17d6810771e9c9c31551d57e5d1efdb.tar.zst godot-a969e2e6f17d6810771e9c9c31551d57e5d1efdb.zip | |
Area2D can now detect overlap with other areas
this should make everything simpler, specially for newcomers to Godot
Diffstat (limited to 'servers/physics_2d/space_2d_sw.cpp')
| -rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index f2ed74ffb..9523e8bf8 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -527,13 +527,20 @@ void* Space2DSW::_broadphase_pair(CollisionObject2DSW *A,int p_subindex_A,Collis if (type_A==CollisionObject2DSW::TYPE_AREA) { - ERR_FAIL_COND_V(type_B!=CollisionObject2DSW::TYPE_BODY,NULL); Area2DSW *area=static_cast<Area2DSW*>(A); - Body2DSW *body=static_cast<Body2DSW*>(B); + if (type_B==CollisionObject2DSW::TYPE_AREA) { + + Area2DSW *area_b=static_cast<Area2DSW*>(B); + Area2Pair2DSW *area2_pair = memnew(Area2Pair2DSW(area_b,p_subindex_B,area,p_subindex_A) ); + return area2_pair; + } else { + + Body2DSW *body=static_cast<Body2DSW*>(B); + AreaPair2DSW *area_pair = memnew(AreaPair2DSW(body,p_subindex_B,area,p_subindex_A) ); + return area_pair; + } - AreaPair2DSW *area_pair = memnew(AreaPair2DSW(body,p_subindex_B,area,p_subindex_A) ); - return area_pair; } else { |
