Skip to content

Commit

Permalink
Update to ASA v2.11 (microsoft#241)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
fast-slow-still authored Nov 30, 2021
1 parent 4cd7c30 commit 6bded10
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
57 changes: 37 additions & 20 deletions Assets/WorldLocking.ASA/Scripts/PublisherASA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -41,7 +58,7 @@ namespace Microsoft.MixedReality.WorldLocking.ASA
/// </remarks>
public class PublisherASA : MonoBehaviour, IPublisher
{
#region Inspector fields
#region Inspector fields

[Tooltip("Enable coarse relocation")]
[SerializeField]
Expand Down Expand Up @@ -388,7 +405,7 @@ public async void Setup()
#endif // WLT_ASA_INCLUDED
}

#region Implementation of IPublisher
#region Implementation of IPublisher
/// <inheritdocs />
public ReadinessStatus Status
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -1057,9 +1074,9 @@ record = await DownloadRecord(cloudAnchorId);
}


#endregion // Internal implementations
#endregion // Internal implementations

#region Internal helpers
#region Internal helpers

/// <summary>
/// Convert the collection of ids to an array.
Expand Down Expand Up @@ -1214,10 +1231,10 @@ private async Task<LocalPeg> 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
Expand All @@ -1227,7 +1244,7 @@ private async Task<LocalPeg> InternalCreateLocalPeg(string id, Pose lockedPose)
return peg;
}

#region TRASH
#region TRASH

#if WLT_EXTRA_LOGGING
private static void PrintScene()
Expand Down Expand Up @@ -1271,7 +1288,7 @@ private static void PrintSubtree(int consolePriority, Transform subroot, int ind
}
#endif // WLT_EXTRA_LOGGING

#endregion // TRASH
#endregion // TRASH

/// <summary>
/// If cloud anchor id is unknown, add the record, else update the record.
Expand Down Expand Up @@ -1342,15 +1359,15 @@ private async Task<AnchorRecord> 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")}");
#else // Android/iOS
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.");
Expand All @@ -1361,9 +1378,9 @@ private async Task<AnchorRecord> RecordFromCloud(AnchorRecord record)
return record;
}

#endregion // Internal helpers
#endregion // Internal helpers

#region ASA events
#region ASA events

/// <summary>
/// Put incoming cloud anchors (from ASA thread) into a list for processing on main thread.
Expand Down Expand Up @@ -1426,9 +1443,9 @@ private void OnASAError(object sender, SessionErrorEventArgs args)
);
}

#endregion // ASA events
#endregion // ASA events

#region Setup helpers
#region Setup helpers

/// <summary>
/// Create a location provider if coarse relocation is enabled.
Expand Down Expand Up @@ -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[]
Expand Down Expand Up @@ -1622,7 +1639,7 @@ private void PermissionCallback_Denied(string permission)
waitingState = PermissionWaiting.Denied;
}
#endif
#endregion // Awful stuff
#endregion // Awful stuff

#endif // WLT_ASA_INCLUDED
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions UPM/asa_files/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions UPM/asa_files/package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions UPM/asa_samples_files/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions UPM/asa_samples_files/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions UPM/core_files/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion UPM/core_files/package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
2 changes: 2 additions & 0 deletions UPM/samples_files/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions UPM/samples_files/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 6bded10

Please sign in to comment.