Browse Source

Merge pull request #18349 from Gorgexpress/master

Fixed 2D intersect_shape limiting broadphase results
Max Hilbrunner 7 years ago
parent
commit
e790d4aafa
1 changed files with 4 additions and 1 deletions
  1. 4 1
      servers/physics_2d/space_2d_sw.cpp

+ 4 - 1
servers/physics_2d/space_2d_sw.cpp

@@ -181,12 +181,15 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
 	Rect2 aabb = p_xform.xform(shape->get_aabb());
 	Rect2 aabb = p_xform.xform(shape->get_aabb());
 	aabb = aabb.grow(p_margin);
 	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;
 	int cc = 0;
 
 
 	for (int i = 0; i < amount; i++) {
 	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))
 		if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask))
 			continue;
 			continue;