-
Notifications
You must be signed in to change notification settings - Fork 69
Support interacting with ARKit XR system in external native modules #260
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
Changes from all commits
981210e
5bf368b
95c329e
de94ac7
806fb46
a3c957b
da5433d
f0f09ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,3 +183,47 @@ namespace Babylon::Plugins::NativeXr | |
| } | ||
| #endif | ||
| #endif | ||
|
|
||
| #if __has_include("IXrContextARKit.h") | ||
| #include "IXrContextARKit.h" | ||
| #if __has_include("jsi/jsi.h") | ||
| namespace Babylon::Plugins::NativeXr | ||
| { | ||
| bool TryGetNativeAnchor(facebook::jsi::Runtime& jsiRuntime, facebook::jsi::Value& jsAnchor, ARAnchor*& nativeAnchor) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I prefer to use reference to pointer, but I feel like the pattern in OpenXR/Vulkan/D3D is usually to do pointer to pointer. Idk which is actually better, just wanted to point it out
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, without looking too hard I think the first two references could be const all the way down
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree on switching things that aren't getting set to constants. I think that a reference to a pointer is more legible than a double pointer personally.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going to leave things as they are for now. jsiRuntime.global() isn't marked as a const operation so we can get away with handing around a const jsiRuntime here. |
||
| { | ||
| nativeAnchor = nullptr; | ||
| uintptr_t nativeAnchorPtr{reinterpret_cast<uintptr_t>(nullptr)}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could use auto here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. going to leave as uintptr_t to stay consistent with rest of file/avoid editing the rest of the file. |
||
| if (TryGetNativeAnchor(jsiRuntime, jsAnchor, nativeAnchorPtr)) | ||
| { | ||
| nativeAnchor = reinterpret_cast<ARAnchor*>(nativeAnchorPtr); | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } | ||
| #endif | ||
| #if __has_include("napi/env.h") | ||
| namespace Babylon::Plugins::NativeXr | ||
| { | ||
| bool TryGetNativeAnchor(Napi::Env env, Napi::Value anchor, ARAnchor*& nativeAnchor) | ||
| { | ||
| nativeAnchor = nullptr; | ||
| uintptr_t nativeAnchorPtr{reinterpret_cast<uintptr_t>(nullptr)}; | ||
| if (TryGetNativeAnchor(env, anchor, nativeAnchorPtr)) | ||
| { | ||
| nativeAnchor = reinterpret_cast<ARAnchor*>(nativeAnchorPtr); | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| bool TryDeclareNativeAnchor(Napi::Env env, const Napi::Value& session, ARAnchor* nativeAnchor, Napi::Value& xrAnchor) | ||
| { | ||
| uintptr_t nativeAnchorPtr{reinterpret_cast<uintptr_t>(nativeAnchor)}; | ||
| return TryDeclareNativeAnchor(env, session, nativeAnchorPtr, xrAnchor); | ||
| } | ||
| } | ||
| #endif | ||
| #endif | ||
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.
This feels like something that should be handled at the CMake level (like we do with AppRuntime* etc) instead of doing compile-time if's
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.
these files can be referenced by anyone independent of whether they use cmake