Skip to content

Support multiple intersections for ray casting #108022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

tucono
Copy link

@tucono tucono commented Jun 26, 2025

Largely an update of PR #91303 (handling godotengine/godot-proposals#9059 and godotengine/godot-proposals#2616) to support Jolt Physics - however there are a few key differences.

This PR is to support multiple collisions for raycasts in 2D and 3D space provided by a new intersect_ray_multiple function. This function behaves somewhat similarly to the intersect_point methods which are provided a maximum number of allowable collisions. Once that number has been reached, the function will return (potentially not yielding all collisions along the raycast). However, if the maximum number of collisions provided is 1, then it will behave the same as the current intersect_ray method and return only the closest intersection.

The return is an unsorted array of dictionaries with the same parameters as the current intersect_ray methods. One curiosity I have seen between Jolt and Godot Physics is that Godot Physics only provides the closest hit on a convex mesh collision shape whereas Jolt provides all collisions where the normal is opposed to the raycast.
image

I've tried to do a good amount of testing with some simple documentation in the attached pdf. However, I doubt I have tested all possibilities since there are a large number of options for raycasts. I would highly welcome any additional testing.
Validation.pdf

@tucono tucono requested review from a team as code owners June 26, 2025 18:51
@Calinou Calinou added this to the 4.x milestone Jun 26, 2025
@AThousandShips AThousandShips changed the title Add multiple intersections raycast Support multiple intersections for ray casting Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants