godotengine / godotengine/godot

PhysicsDirectSpaceState2D.intersect_shape stops working when there are lots of Area2Ds

Open
#94,367 2 comments 1 reaction 0 assignees View on GitHub
bug confirmed documentation topic:2d topic:physics
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.
![GIF 7-14-2024 5-39-03 PM](https://github.com/user-attachments/assets/6f48a567-11da-4ab6-8068-dd65d9731287)
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.