Add intersects_ray()
method to OpenXRCompositionLayer
#90286
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up to PR #89880
As discussed on this comment, since these composition layers are most likely going to be used for UI, developers will want to cast a ray and get the collision point. And given that two of the layer types (cylinder and equirect) are curved and all can be rotated and moved around, developers aren't going to want to independently figure out the math for that. :-)
So, this PR adds
OpenXRCompositionLayer::intersects_ray()
which returns UV coordinates where the ray intersects.The main thing I'm unsure about is that its returns
Vector2(-1.0, -1.0)
in the case that there is no collision. An alternative would be to change the return type toVariant
so we can returnVector2
when there is an intersection andnull
when there isn't, but that would make it impossible to use proper type hints. I'm not sure which alternative is better, but I have a slight preference for the former, so that's the one I went with.Here is a test project (doesn't include the 'godot_openxr_vendors' plugin - you'll need to download that yourself):
openxr_composition_layer_test.zip