diff options
author | Michael <gorgexpress@gmail.com> | 2018-04-22 04:16:55 -0400 |
---|---|---|
committer | Michael <gorgexpress@gmail.com> | 2018-04-22 06:01:29 -0400 |
commit | 1ba106a71e6c0550ebf95d9563995d0266cfecb1 (patch) | |
tree | d87737bdff002cfe429354955c3cda8a874e030b | |
parent | 6b797574a2a238968211daa6c731bae56e7bff05 (diff) |
Fixed 2D intersect_shape limiting broadphase results
Physics2DDirectSpaceStateSW was applying the result limit to broadphase
collision detection instead of narrow. This is inconsistent with its 3D
variant, as well as the rest of the 2D direct space state functions.
Broadphase is now limited by INTERSECTION_QUERY_MAX like everything else,
and narrow phase is exited early when the result limit has been reached.
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index c29093d1af..b42f1b0df3 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -180,12 +180,15 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans Rect2 aabb = p_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); - int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, p_result_max, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space2DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); int cc = 0; for (int i = 0; i < amount; i++) { + if (cc >= p_result_max) + break; + if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask)) continue; |