Skip to content

Commit

Permalink
Merge branch 'release/5.5.0' into 'main'
Browse files Browse the repository at this point in the history
Release 5.5.0

See merge request xr/integrations/unityplugin!178
  • Loading branch information
JuliaRonnebergerUL committed Mar 17, 2022
2 parents 3f74930 + c305054 commit aac368d
Show file tree
Hide file tree
Showing 26 changed files with 9,415 additions and 5,749 deletions.
6 changes: 6 additions & 0 deletions Packages/Tracking OpenXR/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[docs-website]: https://docs.ultraleap.com/ "Ultraleap Docs"

## [1.0.0-pre.2] - 15/03/2022

### Fixed

- Fixed a marshalling issue that resulted in crashes when errors during creation of OpenXR hand trackers.

## [1.0.0-pre.1]

### Added
Expand Down
Binary file not shown.
Git LFS file not shown
49 changes: 23 additions & 26 deletions Packages/Tracking OpenXR/Runtime/Scripts/HandTrackingFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Ultraleap.Tracking.OpenXR
Category = FeatureCategory.Feature,
Required = false,
OpenxrExtensionStrings = "XR_EXT_hand_tracking",
BuildTargetGroups = new[] { BuildTargetGroup.Standalone, BuildTargetGroup.Android }
BuildTargetGroups = new[] {BuildTargetGroup.Standalone, BuildTargetGroup.Android}
)]
#endif
public class HandTrackingFeature : OpenXRFeature
Expand All @@ -37,17 +37,6 @@ private static class Native
private const string NativeDLL = "UltraleapOpenXRUnity";
private const string NativePrefix = "Unity_HandTrackingFeature_";

[StructLayout(LayoutKind.Sequential, Pack = 8)]
internal readonly struct Result
{
public bool Succeeded => _result >= 0;
public bool Failed => _result < 0;
[CanBeNull] public string Message => _message;

private readonly int _result;
[MarshalAs(UnmanagedType.LPStr)] private readonly string _message;
}

[DllImport(NativeDLL, EntryPoint = NativePrefix + "HookGetInstanceProcAddr", ExactSpelling = true)]
internal static extern IntPtr HookGetInstanceProcAddr(IntPtr func);

Expand All @@ -70,19 +59,24 @@ internal readonly struct Result
internal static extern void OnAppSpaceChange(ulong xrSpace);

[DllImport(NativeDLL, EntryPoint = NativePrefix + "CreateHandTrackers", ExactSpelling = true)]
internal static extern Result CreateHandTrackers();
internal static extern int CreateHandTrackers();

[DllImport(NativeDLL, EntryPoint = NativePrefix + "DestroyHandTrackers", ExactSpelling = true)]
internal static extern Result DestroyHandTrackers();
internal static extern int DestroyHandTrackers();

[DllImport(NativeDLL, EntryPoint = NativePrefix + "LocateHandJoints", ExactSpelling = true)]
internal static extern Result LocateHandJoints(
internal static extern int LocateHandJoints(
Handedness chirality,
FrameTime frameTime,
out uint isActive,
[Out, NotNull, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)]
HandJointLocation[] joints,
uint jointCount);

[DllImport(NativeDLL, EntryPoint = NativePrefix + "XrResultToString", ExactSpelling = true)]
private static extern IntPtr XrResultToString(int result);

internal static string ResultToString(int result) => Marshal.PtrToStringAnsi(XrResultToString(result));
}

protected override IntPtr HookGetInstanceProcAddr(IntPtr func) => Native.HookGetInstanceProcAddr(func);
Expand Down Expand Up @@ -111,33 +105,36 @@ protected override bool OnInstanceCreate(ulong xrInstance)

protected override void OnSubsystemStart()
{
Native.Result result = Native.CreateHandTrackers();
if (result.Failed)
int result = Native.CreateHandTrackers();
if (IsResultFailure(result))
{
Debug.LogError(result.Message);
Debug.LogError($"Failed to create hand-trackers: {Native.ResultToString(result)}");
}
}

protected override void OnSubsystemStop()
{
Native.Result result = Native.DestroyHandTrackers();
if (result.Failed)
int result = Native.DestroyHandTrackers();
if (IsResultFailure(result))
{
Debug.LogError(result.Message);
Debug.LogError($"Failed to destroy hand-trackers: {Native.ResultToString(result)}");
}
}

internal bool LocateHandJoints(Handedness handedness, FrameTime frameTime, HandJointLocation[] handJointLocations)
{
Native.Result result = Native.LocateHandJoints(handedness, frameTime, out uint isActive, handJointLocations, (uint)handJointLocations.Length);
if (result.Failed)
int result = Native.LocateHandJoints(handedness, frameTime, out uint isActive, handJointLocations, (uint)handJointLocations.Length);
if (IsResultFailure(result))
{
Debug.LogError(result.Message);
Debug.LogError($"Failed to locate hand-joints: {Native.ResultToString(result)}");
return false;
}

return result.Succeeded && Convert.ToBoolean(isActive);
return Convert.ToBoolean(isActive);
}

// All OpenXR error codes are negative.
private static bool IsResultFailure(int result) => result < 0;

#if UNITY_EDITOR
protected override void GetValidationChecks(List<ValidationRule> rules, BuildTargetGroup targetGroup)
{
Expand Down
2 changes: 1 addition & 1 deletion Packages/Tracking OpenXR/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.ultraleap.tracking.openxr",
"version": "1.0.0-pre.1",
"version": "1.0.0-pre.2",
"displayName": "Ultraleap Tracking OpenXR",
"description": "Support for OpenXR Hand Tracking",
"unity": "2020.3",
Expand Down
2 changes: 1 addition & 1 deletion Packages/Tracking Preview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.ultraleap.tracking.preview",
"version": "5.4.0",
"version": "5.5.0",
"description": "Ultraleap Tracking Preview",
"displayName": "Ultraleap Tracking Preview",
"unity": "2019.4",
Expand Down
27 changes: 27 additions & 0 deletions Packages/Tracking/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[docs-website]: https://docs.ultraleap.com/ "Ultraleap Docs"

## [5.5.0] - 17/03/2022

### Added
- Hand Binder Scale feature, uniformly scale the 3D model model up or down based on the ratio between the leap data and the 3D model. This will require a rebind to calculate the correct scale.
- tracking service version check for multiple device mode. Warning appears if trying to select the 'specific' multi device mode in a service version < 5.3.6

### Changed
- Serial numbers for 'multiple device mode' = 'Specific' can be chosen from a drop down list in the inspector instead of a text field. Using Device indices is no longer supported.

### Removed
- x86 LeapC.dll

### Fixed
- Dynamic UI scene - blocks sometimes did not expand when undocked
- Capsule hands appear small compared to size of 'IR hands' of user using HDRP / URP and do not line up. Using standard rendering on Unity 2019.4 LTS hands are usually not visible (but are being tracked). When they appear they do not line up with the hands in the image.
- A check has been added to ensure a subscription to device events won't happen if the leapProvider is null.

### Known issues
- Scenes containing the infrared viewer render incorrectly on systems using single pass stereo with the XR plugin system - e.g. Windows Mixed Reality headsets. SteamVR headsets may also default to single pass stereo, showing the same issue. However in this case, the OpenVR settings can be changed to multipass which resolves the problem.
- Demo scenes do not start at the correct height for a seated user. The XR Plugin Management System adjusts the camera height. This means the user has to adjust components in the scene to the correct height - e.g. camera height. Currently our position is to support the legacy XR system height settings.
- Possible hand offset issues on XR2 headsets using SVR plugin
- Hands in Desktop scenes can appear far away from the camera
- Interactions callback scene allows blocks to be moved without doing a grasp pose.
- Interactions object scene platform/stage seems to move a lot
- Dynamic UI objects throwing backwards most of the time.


## [5.4.0]

### Added
Expand Down
84 changes: 82 additions & 2 deletions Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class LeapServiceProviderEditor : CustomEditorBase<LeapServiceProvider>
private LeapServiceProvider _leapServiceProvider;
private Controller _leapController;

private List<string> _serialNumbers;
private int _chosenDeviceIndex;

protected override void OnEnable()
{
Expand All @@ -59,10 +61,13 @@ protected override void OnEnable()
(int)LeapServiceProvider.PhysicsExtrapolationMode.Manual,
"_physicsExtrapolationTime");

specifyCustomDrawer("_multipleDeviceMode", multiDeviceToggleWithVersionCheck);
specifyConditionalDrawing("_multipleDeviceMode",
(int)LeapServiceProvider.MultipleDeviceMode.Specific,
"_specificSerialNumber");

specifyCustomDrawer("_specificSerialNumber", drawSerialNumberToggle);

deferProperty("_serverNameSpace");
deferProperty("_workerThreadProfiling");

Expand Down Expand Up @@ -100,6 +105,47 @@ private void frameOptimizationWarning(SerializedProperty property)
EditorGUILayout.HelpBox(warningText, MessageType.Warning);
}

private void multiDeviceToggleWithVersionCheck(SerializedProperty property)
{
// this is the minimum service version that supports Multiple devices
LEAP_VERSION minimumServiceVersion = new LEAP_VERSION { major = 5, minor = 3, patch = 6 };

if (LeapController.IsConnected && !LeapController.CheckRequiredServiceVersion(minimumServiceVersion) && property.enumValueIndex == (int)LeapServiceProvider.MultipleDeviceMode.Specific)
{
property.enumValueIndex = (int)LeapServiceProvider.MultipleDeviceMode.Disabled;
Debug.LogWarning(String.Format("Your current tracking service does not support 'Multiple Device Mode' = 'Specific' (min version is {0}.{1}.{2}). Please update your service: https://developer.leapmotion.com/tracking-software-download", minimumServiceVersion.major, minimumServiceVersion.minor, minimumServiceVersion.patch));
}

EditorGUILayout.PropertyField(property);
}


private void drawSerialNumberToggle(SerializedProperty property)
{
if (LeapController != null)
{
if (SerialNumbers.Count == 0)
{
EditorGUILayout.HelpBox("There are no devices connected. Connect a device to use the Multiple Device Mode 'Specific'", MessageType.Warning);
return;
}

if (!Application.isPlaying)
{
_chosenDeviceIndex = SerialNumbers.IndexOf(property.stringValue);
if (_chosenDeviceIndex == -1 || _chosenDeviceIndex > SerialNumbers.Count) _chosenDeviceIndex = 0;

_chosenDeviceIndex = EditorGUILayout.Popup("Specific Serial Number", _chosenDeviceIndex, SerialNumbers.ToArray());
property.stringValue = SerialNumbers[_chosenDeviceIndex];
}
else
{
EditorGUILayout.PropertyField(property);
}
}
}


public override void OnInspectorGUI()
{

Expand Down Expand Up @@ -205,15 +251,49 @@ private Controller LeapController

if (this._leapController != null)
{
this._leapController.Device += _leapController_DeviceChanged;
this._leapController.DeviceLost += _leapController_DeviceChanged;
this._leapController.Device += _leapController_DeviceAdded;
this._leapController.DeviceLost += _leapController_DeviceLost;
}

return this._leapController;
}
}
}

private List<string> SerialNumbers
{
get
{
if (this._serialNumbers != null)
{
return this._serialNumbers;
}
else
{
this._serialNumbers = new List<string>();
List<Device> connectedDevices = LeapController.Devices;
foreach (Device d in connectedDevices)
{
this._serialNumbers.Add(d.SerialNumber);
}
return this._serialNumbers;
}
}
}


private void _leapController_DeviceAdded(object sender, DeviceEventArgs e)
{
SerialNumbers.Add(e.Device.SerialNumber);
_leapController_DeviceChanged(sender, e);
}

private void _leapController_DeviceLost(object sender, DeviceEventArgs e)
{
SerialNumbers.Remove(e.Device.SerialNumber);
_leapController_DeviceChanged(sender, e);
}

private void _leapController_DeviceChanged(object sender, DeviceEventArgs e)
{
EditorWindow view = EditorWindow.GetWindow<SceneView>();
Expand Down
20 changes: 19 additions & 1 deletion Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ public void Stop()
_polster.Join();
}

/// <summary>
/// Returns the version of the currently installed Tracking Service.
/// Might return 0.0.0 if no device is connected or it cannot get the current version.
/// </summary>
/// <returns>the current tracking service version</returns>
public LEAP_VERSION GetCurrentServiceVersion()
{
LEAP_VERSION currentVersion = new LEAP_VERSION { major = 0, minor = 0, patch = 0 };
LeapC.GetVersion(_leapConnection, eLeapVersionPart.eLeapVersionPart_ServerLibrary, ref currentVersion);
return currentVersion;
}

//Run in Polster thread, fills in object queues
private void processMessages()
{
Expand Down Expand Up @@ -586,7 +598,13 @@ private void handleDevice(ref LEAP_DEVICE_EVENT deviceMsg)

private void handleLostDevice(ref LEAP_DEVICE_EVENT deviceMsg)
{
Device lost = _devices.FindDeviceByHandle(deviceMsg.device.handle);
IntPtr deviceHandle;
eLeapRS result = LeapC.OpenDevice(deviceMsg.device, out deviceHandle);
if (result != eLeapRS.eLeapRS_Success)
return;

//UnityEngine.Debug.Log("handleLostDevice: " + deviceHandle);
Device lost = _devices.FindDeviceByHandle(deviceHandle);
if (lost != null)
{
_devices.Remove(lost);
Expand Down
21 changes: 21 additions & 0 deletions Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,27 @@ public bool IsServiceConnected
}
}

/// <summary>
/// Checks whether a minimum or required tracking service version is installed.
/// Gets the currently installed service version from the connection and checks whether
/// the argument minServiceVersion is smaller or equal to it
/// </summary>
/// <param name="minServiceVersion">The minimum service version to check against</param>
/// <returns></returns>
public bool CheckRequiredServiceVersion(LEAP_VERSION minServiceVersion)
{
LEAP_VERSION currentServiceVersion = _connection.GetCurrentServiceVersion();

// check that minServiceVersion is smaller or equal to the current service version
if (minServiceVersion.major < currentServiceVersion.major) return true;
else if (minServiceVersion.major == currentServiceVersion.major)
{
if (minServiceVersion.minor < currentServiceVersion.minor) return true;
else if (minServiceVersion.minor == currentServiceVersion.minor && minServiceVersion.patch <= currentServiceVersion.patch) return true;
}
return false;
}

/// <summary>
/// Requests setting a policy.
///
Expand Down
5 changes: 0 additions & 5 deletions Packages/Tracking/Core/Runtime/Plugins/x86.meta

This file was deleted.

5 changes: 0 additions & 5 deletions Packages/Tracking/Core/Runtime/Plugins/x86/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions Packages/Tracking/Core/Runtime/Plugins/x86/LeapC.dll

This file was deleted.

Loading

0 comments on commit aac368d

Please sign in to comment.