From 6bded10d31fd13c164524b06e6b3bec011174a16 Mon Sep 17 00:00:00 2001 From: Mark Finch Date: Tue, 30 Nov 2021 18:43:39 +0000 Subject: [PATCH] Update to ASA v2.11 (#241) * Update to ASA v2.11.0. Also prepares for upgrade to ASA v2.12.0 (removing workarounds). Also adds iOS ASA reference. * Update package generation for creating WLT v1.5.6. --- ...osoft.MixedReality.WorldLocking.ASA.asmdef | 19 ++++++- .../WorldLocking.ASA/Scripts/PublisherASA.cs | 57 ++++++++++++------- .../Scripts/ARF/AnchorManagerARF.cs | 4 +- .../Scripts/ARF/SpongyAnchorARF.cs | 4 +- UPM/asa_files/CHANGELOG.md | 2 + UPM/asa_files/package.json | 4 +- UPM/asa_samples_files/CHANGELOG.md | 2 + UPM/asa_samples_files/package.json | 8 +-- UPM/core_files/CHANGELOG.md | 2 + UPM/core_files/package.json | 2 +- UPM/samples_files/CHANGELOG.md | 2 + UPM/samples_files/package.json | 4 +- 12 files changed, 76 insertions(+), 34 deletions(-) diff --git a/Assets/WorldLocking.ASA/Microsoft.MixedReality.WorldLocking.ASA.asmdef b/Assets/WorldLocking.ASA/Microsoft.MixedReality.WorldLocking.ASA.asmdef index cf6c5c888..308284f88 100644 --- a/Assets/WorldLocking.ASA/Microsoft.MixedReality.WorldLocking.ASA.asmdef +++ b/Assets/WorldLocking.ASA/Microsoft.MixedReality.WorldLocking.ASA.asmdef @@ -6,7 +6,9 @@ "Microsoft.MixedReality.WorldLocking.Core", "Microsoft.MixedReality.WorldLocking.Tools", "AzureSpatialAnchors.SDK.Windows.Runtime", - "AzureSpatialAnchors.SDK.Android.Runtime" + "AzureSpatialAnchors.SDK.Android.Runtime", + "AzureSpatialAnchors.SDK.iOS.Runtime", + "Unity.XR.ARFoundation" ], "includePlatforms": [ "Android", @@ -25,6 +27,21 @@ "name": "com.microsoft.azure.spatial-anchors-sdk.core", "expression": "", "define": "WLT_ASA_INCLUDED" + }, + { + "name": "com.microsoft.azure.spatial-anchors-sdk.core", + "expression": "2.11", + "define": "WLT_ASA_V2_11_0_OR_NEWER" + }, + { + "name": "com.microsoft.azure.spatial-anchors-sdk.core", + "expression": "2.12", + "define": "WLT_ASA_V2_12_0_OR_NEWER" + }, + { + "name": "com.unity.xr.arfoundation", + "expression": "", + "define": "WLT_ARFOUNDATION_PRESENT" } ], "noEngineReferences": false diff --git a/Assets/WorldLocking.ASA/Scripts/PublisherASA.cs b/Assets/WorldLocking.ASA/Scripts/PublisherASA.cs index 73421b45e..54de0f3b6 100644 --- a/Assets/WorldLocking.ASA/Scripts/PublisherASA.cs +++ b/Assets/WorldLocking.ASA/Scripts/PublisherASA.cs @@ -4,6 +4,14 @@ //#define WLT_EXTRA_LOGGING #define WLT_LOG_ASA_SETUP +#if !WLT_ASA_V2_11_0_OR_NEWER +#define WLT_ASA_V2_10_2_OR_OLDER +#endif // WLT_ASA_V2_11_0_OR_NEWER + +#if UNITY_WSA && !WLT_ASA_V2_12_0_OR_NEWER +#define WLT_ASA_SESSION_ORIGIN_WORKAROUND +#endif // UNITY_WSA + #if WLT_DISABLE_LOGGING #undef WLT_EXTRA_LOGGING #undef WLT_LOG_ASA_SETUP @@ -18,7 +26,16 @@ #if WLT_ASA_INCLUDED using Microsoft.Azure.SpatialAnchors; using Microsoft.Azure.SpatialAnchors.Unity; +#if WLT_ASA_V2_10_2_OR_OLDER using NativeAnchor = Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent; +#endif // WLT_ASA_V2_10_2_OR_OLDER +#if WLT_ASA_V2_11_0_OR_NEWER +#if WLT_ARFOUNDATION_PRESENT +using NativeAnchor = UnityEngine.XR.ARFoundation.ARAnchor; +#else // WLT_ARFOUNDATION_PRESENT +#error AR Foundation required for ASA v2.11.0 or newer. Please install AR Foundation package. +#endif // WLT_ARFOUNDATION_PRESENT +#endif // WLT_ASA_V2_11_0_OR_NEWER #endif // WLT_ASA_INCLUDED using Microsoft.MixedReality.WorldLocking.Core; @@ -41,7 +58,7 @@ namespace Microsoft.MixedReality.WorldLocking.ASA /// public class PublisherASA : MonoBehaviour, IPublisher { -#region Inspector fields + #region Inspector fields [Tooltip("Enable coarse relocation")] [SerializeField] @@ -388,7 +405,7 @@ public async void Setup() #endif // WLT_ASA_INCLUDED } -#region Implementation of IPublisher + #region Implementation of IPublisher /// public ReadinessStatus Status { @@ -688,13 +705,13 @@ public async Task PurgeArea(float radius) throw new NotSupportedException("Trying to use PublisherASA without Azure Spatial Anchors installed."); #endif // WLT_ASA_INCLUDED } -#endregion // Implementation of IPublisher + #endregion // Implementation of IPublisher -#endregion // Public API + #endregion // Public API #if WLT_ASA_INCLUDED -#region Internal implementations + #region Internal implementations private static void LogASASetup(string message) { @@ -1057,9 +1074,9 @@ record = await DownloadRecord(cloudAnchorId); } -#endregion // Internal implementations + #endregion // Internal implementations -#region Internal helpers + #region Internal helpers /// /// Convert the collection of ids to an array. @@ -1214,10 +1231,10 @@ private async Task InternalCreateLocalPeg(string id, Pose lockedPose) + $" pa={WorldLockingManager.GetInstance().AnchorManager.AnchorFromSpongy.Inverse().Multiply(frozenPose).position.ToString("F3")}" ); -#if UNITY_WSA +#if WLT_ASA_SESSION_ORIGIN_WORKAROUND // mafinc - workaround for bug in ASA NativeAnchor. peg.anchorHanger.transform.SetLocalPose(Pose.identity); -#endif // UNITY_WSA +#endif // WLT_ASA_SESSION_ORIGIN_WORKAROUND #if WLT_EXTRA_LOGGING // mafinc - trash @@ -1227,7 +1244,7 @@ private async Task InternalCreateLocalPeg(string id, Pose lockedPose) return peg; } -#region TRASH + #region TRASH #if WLT_EXTRA_LOGGING private static void PrintScene() @@ -1271,7 +1288,7 @@ private static void PrintSubtree(int consolePriority, Transform subroot, int ind } #endif // WLT_EXTRA_LOGGING -#endregion // TRASH + #endregion // TRASH /// /// If cloud anchor id is unknown, add the record, else update the record. @@ -1342,7 +1359,7 @@ private async Task RecordFromCloud(AnchorRecord record) Debug.Assert(record.cloudAnchor != null, $"Trying to create native resources from a null cloud anchor"); var wltMgr = WorldLockingManager.GetInstance(); await Task.Yield(); -#if UNITY_WSA +#if WLT_ASA_SESSION_ORIGIN_WORKAROUND Pose spongyPose = record.cloudAnchor.GetPose(); var lockedPose = wltMgr.LockedFromSpongy.Multiply(spongyPose); SimpleConsole.AddLine(ConsoleMid, $"RFC: sp={spongyPose.position.ToString("F3")} lp={lockedPose.position.ToString("F3")}"); @@ -1350,7 +1367,7 @@ private async Task RecordFromCloud(AnchorRecord record) Pose frozenPose = record.cloudAnchor.GetPose(); var lockedPose = wltMgr.LockedFromFrozen.Multiply(frozenPose); SimpleConsole.AddLine(ConsoleMid, $"RFC: fp={frozenPose.position.ToString("F3")} lp={lockedPose.position.ToString("F3")}"); -#endif // UNITY_WSA +#endif // WLT_ASA_SESSION_ORIGIN_WORKAROUND record.localPeg = await InternalCreateLocalPeg(record.cloudAnchorId, lockedPose); AnchorRecord.DebugLog(record, "RecordFromCloud:"); SimpleConsole.AddLine(ConsoleMid, $"Got record={record.cloudAnchorId} with {record.cloudAnchor.AppProperties.Count} properties."); @@ -1361,9 +1378,9 @@ private async Task RecordFromCloud(AnchorRecord record) return record; } -#endregion // Internal helpers + #endregion // Internal helpers -#region ASA events + #region ASA events /// /// Put incoming cloud anchors (from ASA thread) into a list for processing on main thread. @@ -1426,9 +1443,9 @@ private void OnASAError(object sender, SessionErrorEventArgs args) ); } -#endregion // ASA events + #endregion // ASA events -#region Setup helpers + #region Setup helpers /// /// Create a location provider if coarse relocation is enabled. @@ -1528,9 +1545,9 @@ private void ReleaseBusy() Debug.Assert(busy != null); busy = null; } -#endregion // Setup helpers + #endregion // Setup helpers -#region Awful stuff + #region Awful stuff #if UNITY_ANDROID private static readonly string[] androidPermissions = new string[] @@ -1622,7 +1639,7 @@ private void PermissionCallback_Denied(string permission) waitingState = PermissionWaiting.Denied; } #endif -#endregion // Awful stuff + #endregion // Awful stuff #endif // WLT_ASA_INCLUDED } diff --git a/Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs b/Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs index 9afe667d7..349abfae5 100644 --- a/Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs +++ b/Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs @@ -9,9 +9,9 @@ #if UNITY_2020_1_OR_NEWER -#if UNITY_2020_4_OR_NEWER +#if UNITY_2020_3_OR_NEWER #define WLT_ADD_ANCHOR_COMPONENT -#endif // UNITY_2020_4_OR_NEWER +#endif // UNITY_2020_3_OR_NEWER #if WLT_ARFOUNDATION_PRESENT diff --git a/Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs b/Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs index 25d007e81..c80bff5c1 100644 --- a/Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs +++ b/Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs @@ -3,9 +3,9 @@ #if UNITY_2020_1_OR_NEWER -#if UNITY_2020_4_OR_NEWER +#if UNITY_2020_3_OR_NEWER #define WLT_ADD_ANCHOR_COMPONENT -#endif // UNITY_2020_4_OR_NEWER +#endif // UNITY_2020_3_OR_NEWER using UnityEngine; #if WLT_ARFOUNDATION_PRESENT diff --git a/UPM/asa_files/CHANGELOG.md b/UPM/asa_files/CHANGELOG.md index ff67d48a6..b7f4aa1e7 100644 --- a/UPM/asa_files/CHANGELOG.md +++ b/UPM/asa_files/CHANGELOG.md @@ -2,6 +2,8 @@ [See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases) +## 1.5.6 - Update to ASA v2.11.0. + ## 1.5.4 - Fix timing issue with ASA anchors sometimes not created in time. ## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4. diff --git a/UPM/asa_files/package.json b/UPM/asa_files/package.json index e34370e9a..cf6c02c4d 100644 --- a/UPM/asa_files/package.json +++ b/UPM/asa_files/package.json @@ -1,7 +1,7 @@ { "name": "com.microsoft.mixedreality.wlt.asa", "displayName": "WLT-ASA", - "version": "1.5.4", + "version": "1.5.6", "unity": "2020.3", "msftFeatureCategory": "World Locking Tools", "description": "World Locking Tools for Unity (WLT) + Azure Spatial Anchors (ASA)\n\nThis optional add-on to WLT leverages ASA to persist coordinate spaces across sessions and share them across devices.\nCross platform support includes HoloLens, Android, and iOS.", @@ -35,7 +35,7 @@ }, "dependencies": { "com.microsoft.azure.spatial-anchors-sdk.core": "2.9.0", - "com.microsoft.mixedreality.worldlockingtools": "1.5.4" + "com.microsoft.mixedreality.worldlockingtools": "1.5.6" }, "files": [ "WorldLocking.ASA", diff --git a/UPM/asa_samples_files/CHANGELOG.md b/UPM/asa_samples_files/CHANGELOG.md index ff67d48a6..b7f4aa1e7 100644 --- a/UPM/asa_samples_files/CHANGELOG.md +++ b/UPM/asa_samples_files/CHANGELOG.md @@ -2,6 +2,8 @@ [See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases) +## 1.5.6 - Update to ASA v2.11.0. + ## 1.5.4 - Fix timing issue with ASA anchors sometimes not created in time. ## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4. diff --git a/UPM/asa_samples_files/package.json b/UPM/asa_samples_files/package.json index 76c2e9530..3b62894f6 100644 --- a/UPM/asa_samples_files/package.json +++ b/UPM/asa_samples_files/package.json @@ -1,7 +1,7 @@ { "name": "com.microsoft.mixedreality.wlt.asa.samples", "displayName": "WLT-ASA Samples", - "version": "1.5.4", + "version": "1.5.6", "unity": "2020.3", "msftFeatureCategory" : "World Locking Tools", "description": "Example scenes and scripts leveraging Azure Space Anchors (ASA) to persist World Locked coordinate spaces across sessions and share across devices.\n\nFurther samples available at\nhttps://microsoft.github.io/MixedReality-WorldLockingTools-Samples/README.html", @@ -36,9 +36,9 @@ "dependencies": { "com.microsoft.azure.spatial-anchors-sdk.core": "2.9.0", "com.microsoft.mixedreality.toolkit.foundation": "2.7.0", - "com.microsoft.mixedreality.wlt.asa": "1.5.4", - "com.microsoft.mixedreality.worldlockingtools": "1.5.4", - "com.microsoft.mixedreality.worldlockingsamples": "1.5.4" + "com.microsoft.mixedreality.wlt.asa": "1.5.6", + "com.microsoft.mixedreality.worldlockingtools": "1.5.6", + "com.microsoft.mixedreality.worldlockingsamples": "1.5.6" }, "files": [ "package.json.meta", diff --git a/UPM/core_files/CHANGELOG.md b/UPM/core_files/CHANGELOG.md index 8292403f8..a0b25490a 100644 --- a/UPM/core_files/CHANGELOG.md +++ b/UPM/core_files/CHANGELOG.md @@ -2,6 +2,8 @@ [See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases) +## 1.5.6 - Update to ASA v2.11.0. + ## 1.5.4 - Backward compatibility for Unity 2018 .NET backend. ## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4. diff --git a/UPM/core_files/package.json b/UPM/core_files/package.json index d6b1fba71..28809ff46 100644 --- a/UPM/core_files/package.json +++ b/UPM/core_files/package.json @@ -1,7 +1,7 @@ { "name": "com.microsoft.mixedreality.worldlockingtools", "displayName": "WLT Core", - "version": "1.5.4", + "version": "1.5.6", "unity": "2018.4", "msftFeatureCategory" : "World Locking Tools", "description": "World Locking Tools for Unity (WLT)\n\nLock AR virtual space to physical space automatically and intuitively, without requiring application management of anchors.\nPreserve object relative layout, while remaining perceptually stationary in the physical world.", diff --git a/UPM/samples_files/CHANGELOG.md b/UPM/samples_files/CHANGELOG.md index 90f9cbeb6..511717106 100644 --- a/UPM/samples_files/CHANGELOG.md +++ b/UPM/samples_files/CHANGELOG.md @@ -2,6 +2,8 @@ [See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases) +## 1.5.6 - Update to ASA v2.11.0. + ## 1.5.4 - Compatibility for Unity 2018 .NET backend. ## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4. diff --git a/UPM/samples_files/package.json b/UPM/samples_files/package.json index fca5b4b97..3c8ea77c5 100644 --- a/UPM/samples_files/package.json +++ b/UPM/samples_files/package.json @@ -1,7 +1,7 @@ { "name": "com.microsoft.mixedreality.worldlockingsamples", "displayName": "WLT Samples", - "version": "1.5.4", + "version": "1.5.6", "unity": "2018.4", "msftFeatureCategory" : "World Locking Tools", "description": "Basic examples for World Locking Tools.\n\nFurther samples available at\nhttps://microsoft.github.io/MixedReality-WorldLockingTools-Samples/README.html", @@ -32,7 +32,7 @@ }, "dependencies": { "com.microsoft.mixedreality.toolkit.foundation": "2.7.0", - "com.microsoft.mixedreality.worldlockingtools": "1.5.4" + "com.microsoft.mixedreality.worldlockingtools": "1.5.6" }, "files": [ "package.json.meta",