Skip to content

Support interacting with ARKit XR system in external native modules#260

Merged
chrisfromwork merged 8 commits intoBabylonJS:masterfrom
chrisfromwork:iosContext
Jul 20, 2021
Merged

Support interacting with ARKit XR system in external native modules#260
chrisfromwork merged 8 commits intoBabylonJS:masterfrom
chrisfromwork:iosContext

Conversation

@chrisfromwork
Copy link
Copy Markdown
Contributor

@chrisfromwork chrisfromwork commented Jul 20, 2021

This review contains the following changes:

  1. XrAnchorHelper and XrContextHelper are updated to support ARKit types
  2. BabylonNative dependencies are updated

Testing changes:

  1. Azures spatial anchors scenarios in external submodules utilize both of these headers. Changes were validated on both iOS and android.

#if __has_include("jsi/jsi.h")
namespace Babylon::Plugins::NativeXr
{
bool TryGetNativeAnchor(facebook::jsi::Runtime& jsiRuntime, facebook::jsi::Value& jsAnchor, ARAnchor*& nativeAnchor)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

bool TryGetNativeAnchor(facebook::jsi::Runtime& jsiRuntime, facebook::jsi::Value& jsAnchor, ARAnchor*& nativeAnchor)
{
nativeAnchor = nullptr;
uintptr_t nativeAnchorPtr{reinterpret_cast<uintptr_t>(nullptr)};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use auto here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 __has_include("IXrContextARKit.h")
#include "IXrContextARKit.h"
#if __has_include("jsi/jsi.h")
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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

@chrisfromwork chrisfromwork merged commit a8ca60b into BabylonJS:master Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants