From 981210eda17f3a1486f734fcd15fdf2aa4d169a7 Mon Sep 17 00:00:00 2001 From: test Date: Mon, 19 Jul 2021 12:04:28 -0700 Subject: [PATCH 1/7] add ios helper functions --- .../ios/include/glslang/build_info.h | 62 +++++++++++++++++++ .../react-native/shared/XrAnchorHelper.h | 44 +++++++++++++ .../react-native/shared/XrContextHelper.h | 38 ++++++++++++ .../react-native/submodules/BabylonNative | 2 +- 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 Modules/@babylonjs/react-native/ios/include/glslang/build_info.h diff --git a/Modules/@babylonjs/react-native/ios/include/glslang/build_info.h b/Modules/@babylonjs/react-native/ios/include/glslang/build_info.h new file mode 100644 index 000000000..2fee3d651 --- /dev/null +++ b/Modules/@babylonjs/react-native/ios/include/glslang/build_info.h @@ -0,0 +1,62 @@ +// Copyright (C) 2020 The Khronos Group Inc. +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of The Khronos Group Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#ifndef GLSLANG_BUILD_INFO +#define GLSLANG_BUILD_INFO + +#define GLSLANG_VERSION_MAJOR 11 +#define GLSLANG_VERSION_MINOR 4 +#define GLSLANG_VERSION_PATCH 0 +#define GLSLANG_VERSION_FLAVOR "" + +#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \ + (((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ + (((minor) > GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ + ((patch) > GLSLANG_VERSION_PATCH))))) + +#define GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch) \ + (((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ + (((minor) > GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ + ((patch) >= GLSLANG_VERSION_PATCH))))) + +#define GLSLANG_VERSION_LESS_THAN(major, minor, patch) \ + (((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ + (((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ + ((patch) < GLSLANG_VERSION_PATCH))))) + +#define GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch) \ + (((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ + (((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ + ((patch) <= GLSLANG_VERSION_PATCH))))) + +#endif // GLSLANG_BUILD_INFO diff --git a/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h b/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h index 9c35a89f5..ad4672b06 100644 --- a/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h +++ b/Modules/@babylonjs/react-native/shared/XrAnchorHelper.h @@ -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) + { + nativeAnchor = nullptr; + uintptr_t nativeAnchorPtr{reinterpret_cast(nullptr)}; + if (TryGetNativeAnchor(jsiRuntime, jsAnchor, nativeAnchorPtr)) + { + nativeAnchor = reinterpret_cast(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(nullptr)}; + if (TryGetNativeAnchor(env, anchor, nativeAnchorPtr)) + { + nativeAnchor = reinterpret_cast(nativeAnchorPtr); + return true; + } + + return false; + } + + bool TryDeclareNativeAnchor(Napi::Env env, const Napi::Value& session, ARAnchor* nativeAnchor, Napi::Value& xrAnchor) + { + uintptr_t nativeAnchorPtr{reinterpret_cast(nativeAnchor)}; + return TryDeclareNativeAnchor(env, session, nativeAnchorPtr, xrAnchor); + } +} +#endif +#endif diff --git a/Modules/@babylonjs/react-native/shared/XrContextHelper.h b/Modules/@babylonjs/react-native/shared/XrContextHelper.h index 2e18d0cae..963cae421 100644 --- a/Modules/@babylonjs/react-native/shared/XrContextHelper.h +++ b/Modules/@babylonjs/react-native/shared/XrContextHelper.h @@ -139,3 +139,41 @@ 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 TryGetXrContext(facebook::jsi::Runtime& jsiRuntime, IXrContextARKit*& xrContext) + { + xrContext = nullptr; + uintptr_t nativePtr{reinterpret_cast(nullptr)}; + if (TryGetXrContext(jsiRuntime, "ARKit", nativePtr)) + { + xrContext = reinterpret_cast(nativePtr); + return true; + } + + return false; + } +} +#endif +#if __has_include("napi/env.h") +namespace Babylon::Plugins::NativeXr +{ + bool TryGetXrContext(Napi::Env env, IXrContextARKit*& xrContext) + { + xrContext = nullptr; + uintptr_t nativePtr{reinterpret_cast(nullptr)}; + if (TryGetXrContext(env, "ARKit", nativePtr)) + { + xrContext = reinterpret_cast(nativePtr); + return true; + } + + return false; + } +} +#endif +#endif diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index dd9e316dc..dc718f206 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit dd9e316dc6f3396f9ee045a5a565095381e53ad6 +Subproject commit dc718f20667c3f54ae57aacd6b342b35a12653ab From 5bf368bda2b07e39ff9db58f8b32279c9c25c9a0 Mon Sep 17 00:00:00 2001 From: test Date: Mon, 19 Jul 2021 13:06:42 -0700 Subject: [PATCH 2/7] update bn --- Modules/@babylonjs/react-native/submodules/BabylonNative | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index dc718f206..982ae9894 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit dc718f20667c3f54ae57aacd6b342b35a12653ab +Subproject commit 982ae98940e507dc54d546fe97ddbdec2d60cee9 From 95c329e2cc1332e72ac42306a6f8294734df07e2 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 20 Jul 2021 09:58:47 -0700 Subject: [PATCH 3/7] update babylon native dependencies --- Modules/@babylonjs/react-native/submodules/BabylonNative | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index 982ae9894..8f03f4930 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit 982ae98940e507dc54d546fe97ddbdec2d60cee9 +Subproject commit 8f03f49303d99db9ccacb270fee6a1b0bef50a4c From de94ac700cd5b8b402ca94e6122e79398c8cb0f3 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 20 Jul 2021 10:15:03 -0700 Subject: [PATCH 4/7] update BabylonNative dependencies --- Modules/@babylonjs/react-native/submodules/BabylonNative | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index 8f03f4930..c459de589 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit 8f03f49303d99db9ccacb270fee6a1b0bef50a4c +Subproject commit c459de58926eef7f965f0f4a12f24738e2f287b2 From 806fb4678e49d8c552c0f1a91af4de76926f4d38 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 20 Jul 2021 10:18:39 -0700 Subject: [PATCH 5/7] remove unneeded file --- .../ios/include/glslang/build_info.h | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 Modules/@babylonjs/react-native/ios/include/glslang/build_info.h diff --git a/Modules/@babylonjs/react-native/ios/include/glslang/build_info.h b/Modules/@babylonjs/react-native/ios/include/glslang/build_info.h deleted file mode 100644 index 2fee3d651..000000000 --- a/Modules/@babylonjs/react-native/ios/include/glslang/build_info.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2020 The Khronos Group Inc. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// Neither the name of The Khronos Group Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef GLSLANG_BUILD_INFO -#define GLSLANG_BUILD_INFO - -#define GLSLANG_VERSION_MAJOR 11 -#define GLSLANG_VERSION_MINOR 4 -#define GLSLANG_VERSION_PATCH 0 -#define GLSLANG_VERSION_FLAVOR "" - -#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \ - (((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ - (((minor) > GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ - ((patch) > GLSLANG_VERSION_PATCH))))) - -#define GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch) \ - (((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ - (((minor) > GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ - ((patch) >= GLSLANG_VERSION_PATCH))))) - -#define GLSLANG_VERSION_LESS_THAN(major, minor, patch) \ - (((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ - (((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ - ((patch) < GLSLANG_VERSION_PATCH))))) - -#define GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch) \ - (((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ - (((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ - ((patch) <= GLSLANG_VERSION_PATCH))))) - -#endif // GLSLANG_BUILD_INFO From da5433d401dd41f27047f504a8848adb95908675 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 20 Jul 2021 11:47:32 -0700 Subject: [PATCH 6/7] update babylonnative --- Modules/@babylonjs/react-native/submodules/BabylonNative | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index c459de589..90b082b72 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit c459de58926eef7f965f0f4a12f24738e2f287b2 +Subproject commit 90b082b72b0a5e478bfe75bbe8803454d380b653 From f0f09ad2b8b77cc46722f31fcec96f98bfe39c00 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 20 Jul 2021 12:41:35 -0700 Subject: [PATCH 7/7] update to correct commit --- Modules/@babylonjs/react-native/submodules/BabylonNative | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/@babylonjs/react-native/submodules/BabylonNative b/Modules/@babylonjs/react-native/submodules/BabylonNative index 90b082b72..4de24f77a 160000 --- a/Modules/@babylonjs/react-native/submodules/BabylonNative +++ b/Modules/@babylonjs/react-native/submodules/BabylonNative @@ -1 +1 @@ -Subproject commit 90b082b72b0a5e478bfe75bbe8803454d380b653 +Subproject commit 4de24f77ad090e0c7773c20b40b89e3a55730a8b