godotengine / godotengine/godot
PhysicsDirectSpaceState2D.intersect_shape stops working when there are lots of Area2Ds
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
4.2.stable
### System information
Windows 10
### Issue description
Calling the function `PhysicsDirectSpaceState2D.intersect_shape` returns an empty array when there are many nearby overlapping Area2Ds.

In this GIF, the red circle is the intersect_shape call being made every physics frame. The lighter blue circle is the Area2D that we are trying to intersect. The darker blue circle is 3,000 Area2Ds on a separate collision layer.
Notice how the size of the return results array goes to 0 as the mouse gets closer to the 3,000 Area2Ds. You would expect that the results size is 1 as long as the red circle is over the lighter blue circle.
### Steps to reproduce
- Download the MRP
- Enable visible collision shapes
- Try mousing over the Area2Ds
### Minimal reproduction project (MRP)
[IntersectShapeTest.zip](https://github.com/user-attachments/files/16228872/IntersectShapeTest.zip)
Contributor guide
Assessment
This issue has not been assessed yet.