-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add intersects_ray()
method to OpenXRCompositionLayer
#90286
Add intersects_ray()
method to OpenXRCompositionLayer
#90286
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just need to make sure it works in global space.
Also needs a simple demo/test project. Just a simple XR sample that has all 3 composition layers, with a bit of code that uses the UV here to send mouse events/touch events to the viewport so we can verify the obtained UVs are correct.
Coincidentally, I just did that on stream yesterday and remembering the v needed to be 1.0 - v, which may apply here.
Since both I'll update the PR and share my demo project soon! |
9dffa90
to
025f2b8
Compare
@BastiaanOlij Thanks for the review! I've made the requested changes and added a demo project to the PR description above. |
That would probably be true 99% of the time, but just wait for the one person who puts a screen on a moving platform... :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with all the changes :)
Thanks! |
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