diff --git a/ml_lme/LeapIK.cs b/ml_lme/LeapIK.cs index 356239d..8629782 100644 --- a/ml_lme/LeapIK.cs +++ b/ml_lme/LeapIK.cs @@ -2,7 +2,6 @@ namespace ml_lme { - [RequireComponent(typeof(Animator))] [DisallowMultipleComponent] class LeapIK : MonoBehaviour { diff --git a/ml_lme/LeapTracked.cs b/ml_lme/LeapTracked.cs index 78bde4f..11be868 100644 --- a/ml_lme/LeapTracked.cs +++ b/ml_lme/LeapTracked.cs @@ -1,20 +1,19 @@ using ABI_RC.Core.Player; using ABI_RC.Core.Savior; +using RootMotion.FinalIK; using System.Linq; using UnityEngine; namespace ml_lme { - [RequireComponent(typeof(IndexIK))] [DisallowMultipleComponent] class LeapTracked : MonoBehaviour { bool m_enabled = true; bool m_fingersOnly = false; - bool m_calibrated = false; - Animator m_animator = null; IndexIK m_indexIK = null; + VRIK m_vrIK = null; LeapIK m_leapIK = null; Transform m_leftHand = null; @@ -27,58 +26,24 @@ namespace ml_lme m_indexIK = this.GetComponent(); m_knucklesInUse = PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles"); - if((m_indexIK != null) && (m_animator != null)) - { - if(!PlayerSetup.Instance._inVr) - { - // Seems that VR mode always calibrates IndexIK, so let's force it - m_indexIK.avatarAnimator = m_animator; - m_indexIK.Recalibrate(); - } - m_calibrated = true; - - m_indexIK.activeControl = (m_enabled || m_knucklesInUse); - CVRInputManager.Instance.individualFingerTracking = (m_enabled || m_knucklesInUse); - - m_leapIK = m_animator.gameObject.AddComponent(); - m_leapIK.SetEnabled(m_enabled); - m_leapIK.SetFingersOnly(m_fingersOnly); - m_leapIK.SetHands(m_leftHand, m_rightHand); - } + if(PlayerSetup.Instance._inVr) + PlayerSetup.Instance.avatarSetupCompleted.AddListener(this.OnAvatarSetup); } public void SetEnabled(bool p_state) { m_enabled = p_state; - if(m_enabled) + + if(m_indexIK != null) { - if((m_animator != null) && (m_indexIK != null)) - { - m_indexIK.activeControl = true; - if(!m_calibrated && !PlayerSetup.Instance._inVr) - { - m_indexIK.avatarAnimator = m_animator; - m_indexIK.Recalibrate(); - m_calibrated = true; - } - CVRInputManager.Instance.individualFingerTracking = true; - } - } - else - { - if((m_indexIK != null) && m_calibrated) - { - m_indexIK.activeControl = m_knucklesInUse; - CVRInputManager.Instance.individualFingerTracking = m_knucklesInUse; - } + m_indexIK.activeControl = (m_enabled || m_knucklesInUse); + CVRInputManager.Instance.individualFingerTracking = (m_enabled || m_knucklesInUse); } if(m_leapIK != null) m_leapIK.SetEnabled(m_enabled); } - public void SetAnimator(Animator p_animator) => m_animator = p_animator; - public void SetFingersOnly(bool p_state) { m_fingersOnly = p_state; @@ -137,5 +102,66 @@ namespace ml_lme } } } + + public void UpdateTrackingLate(GestureMatcher.GesturesData p_gesturesData) + { + if(m_enabled && !m_fingersOnly && (m_vrIK != null) && m_vrIK.enabled) + { + if(p_gesturesData.m_handsPresenses[0]) + { + IKSolverVR.Arm l_arm = m_vrIK.solver?.leftArm; + if(l_arm?.target != null) + { + if(l_arm.positionWeight < 1f) + l_arm.positionWeight = 1f; + l_arm.target.position = p_gesturesData.m_handsPositons[0]; + + if(l_arm.rotationWeight < 1f) + l_arm.rotationWeight = 1f; + l_arm.target.rotation = p_gesturesData.m_handsRotations[0]; + } + } + + if(p_gesturesData.m_handsPresenses[1]) + { + IKSolverVR.Arm l_arm = m_vrIK.solver?.rightArm; + if(l_arm?.target != null) + { + if(l_arm.positionWeight < 1f) + l_arm.positionWeight = 1f; + l_arm.target.position = p_gesturesData.m_handsPositons[1]; + + if(l_arm.rotationWeight < 1f) + l_arm.rotationWeight = 1f; + l_arm.target.rotation = p_gesturesData.m_handsRotations[1]; + } + } + } + } + + public void OnAvatarClear() + { + m_leapIK = null; + m_vrIK = null; + } + + public void OnAvatarSetup() + { + m_knucklesInUse = PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles"); + + if(m_indexIK != null) + m_indexIK.activeControl = (m_enabled || m_knucklesInUse); + CVRInputManager.Instance.individualFingerTracking = (m_enabled || m_knucklesInUse); + + if(!PlayerSetup.Instance._inVr) + { + m_leapIK = PlayerSetup.Instance._animator.gameObject.AddComponent(); + m_leapIK.SetEnabled(m_enabled); + m_leapIK.SetFingersOnly(m_fingersOnly); + m_leapIK.SetHands(m_leftHand, m_rightHand); + } + else + m_vrIK = PlayerSetup.Instance._animator.GetComponent(); + } } } diff --git a/ml_lme/Main.cs b/ml_lme/Main.cs index 36fe3b5..28e4858 100644 --- a/ml_lme/Main.cs +++ b/ml_lme/Main.cs @@ -1,5 +1,4 @@ -using ABI_RC.Core.InteractionSystem; -using ABI_RC.Core.Player; +using ABI_RC.Core.Player; using ABI_RC.Core.UI; using UnityEngine; @@ -21,6 +20,8 @@ namespace ml_lme GameObject m_leapControllerModel = null; LeapTracked m_leapTracked = null; + static bool ms_vrState = false; + public override void OnApplicationStart() { if(ms_instance == null) @@ -59,6 +60,11 @@ namespace ml_lme null, new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarClear_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)) ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod("SetupAvatarGeneral", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic), + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnSetupAvatarGeneral_Prefix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)), + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnSetupAvatarGeneral_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)) + ); MelonLoader.MelonCoroutines.Start(CreateTrackingObjects()); } @@ -97,6 +103,11 @@ namespace ml_lme m_leapControllerModel.transform.localRotation = Quaternion.identity; } + // Player setup + ms_vrState = PlayerSetup.Instance._inVr; + m_leapTracked = PlayerSetup.Instance.gameObject.AddComponent(); + m_leapTracked.SetHands(m_leapHands[0].transform, m_leapHands[1].transform); + OnSettingsEnableChange(Settings.Enabled); OnSettingsFingersOptionChange(Settings.FingersOnly); OnSettingsModelVisibilityChange(Settings.ModelVisibility); @@ -137,16 +148,22 @@ namespace ml_lme } } + public override void OnLateUpdate() + { + if(ms_vrState && Settings.Enabled && (m_leapTracked != null)) + m_leapTracked.UpdateTrackingLate(m_gesturesData); + } + // Settings changes void OnSettingsEnableChange(bool p_state) { if(p_state) { - m_leapController.StartConnection(); + m_leapController?.StartConnection(); UpdateDeviceTrackingMode(); } else - m_leapController.StopConnection(); + m_leapController?.StopConnection(); if(m_leapTracked != null) m_leapTracked.SetEnabled(p_state); @@ -177,7 +194,7 @@ namespace ml_lme void OnSettingsTrackingModeChange(Settings.LeapTrackingMode p_mode) { - if(Settings.Enabled && (m_leapController != null)) + if(Settings.Enabled) UpdateDeviceTrackingMode(); if(m_leapControllerModel != null) @@ -256,16 +273,16 @@ namespace ml_lme // Internal utility void UpdateDeviceTrackingMode() { - m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null); - m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null); + m_leapController?.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null); + m_leapController?.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null); switch(Settings.TrackingMode) { case Settings.LeapTrackingMode.Screentop: - m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null); + m_leapController?.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null); break; case Settings.LeapTrackingMode.HMD: - m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null); + m_leapController?.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null); break; } } @@ -273,8 +290,11 @@ namespace ml_lme // Leap events void OnLeapDeviceInitialized(object p_sender, Leap.DeviceEventArgs p_args) { - if(Settings.Enabled && (m_leapController != null)) + if(Settings.Enabled) + { + m_leapController?.SubscribeToDeviceEvents(p_args.Device); UpdateDeviceTrackingMode(); + } if(CohtmlHud.Instance != null) CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device initialized"); @@ -288,6 +308,8 @@ namespace ml_lme void OnLeapDeviceLost(object p_sender, Leap.DeviceEventArgs p_args) { + m_leapController?.UnsubscribeFromDeviceEvents(p_args.Device); + if(CohtmlHud.Instance != null) CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device lost"); } @@ -305,37 +327,32 @@ namespace ml_lme } // Patches - static void OnAvatarClear_Postfix(ref PlayerSetup __instance) - { - if((__instance != null) && (__instance == PlayerSetup.Instance)) - ms_instance?.OnAvatarClear(); - } + static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); void OnAvatarClear() { if(m_leapTracked != null) - { - Object.DestroyImmediate(m_leapTracked); - m_leapTracked = null; - } + m_leapTracked.OnAvatarClear(); } - static void OnAvatarSetup_Postfix(ref PlayerSetup __instance) + static void OnAvatarSetup_Postfix() => ms_instance?.OnAvatarSetup(); + void OnAvatarSetup() { - if((__instance != null) && (__instance == PlayerSetup.Instance)) - ms_instance?.OnAvatarSetup(__instance._animator, __instance.GetComponent()); - } - void OnAvatarSetup(Animator p_animator, IndexIK p_indexIK) - { - if(m_leapTracked == null) - { - m_leapTracked = p_indexIK.gameObject.AddComponent(); - m_leapTracked.SetEnabled(Settings.Enabled); - m_leapTracked.SetAnimator(p_animator); - m_leapTracked.SetHands(m_leapHands[0].transform, m_leapHands[1].transform); - m_leapTracked.SetFingersOnly(Settings.FingersOnly); + if(!PlayerSetup.Instance._inVr && (m_leapTracked != null)) + m_leapTracked.OnAvatarSetup(); - OnSettingsHeadAttachChange(Settings.HeadAttach); - } + OnSettingsHeadAttachChange(Settings.HeadAttach); + } + + // Sneaky forced IndexIK calibration + static void OnSetupAvatarGeneral_Prefix(ref PlayerSetup __instance) + { + if(__instance != null) + __instance._inVr = true; + } + static void OnSetupAvatarGeneral_Postfix(ref PlayerSetup __instance) + { + if(__instance != null) + __instance._inVr = ms_vrState; } // Utilities diff --git a/ml_lme/vendor/LeapCSharp/Arm.cs b/ml_lme/vendor/LeapCSharp/Arm.cs index a8c2ec3..1547fc5 100644 --- a/ml_lme/vendor/LeapCSharp/Arm.cs +++ b/ml_lme/vendor/LeapCSharp/Arm.cs @@ -5,6 +5,7 @@ * http://www.apache.org/licenses/LICENSE-2.0, or another agreement * * between Ultraleap and you, your company or other organization. * ******************************************************************************/ +using UnityEngine; namespace Leap { @@ -29,6 +30,7 @@ namespace Leap /// Constructs a new Arm object. /// @since 3.0 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 and Quaternion instead.")] public Arm(Vector elbow, Vector wrist, Vector center, @@ -45,6 +47,25 @@ namespace Leap BoneType.TYPE_METACARPAL, //ignored for arms rotation) { } + /// + /// Constructs a new Arm object. + /// + public Arm(Vector3 elbow, + Vector3 wrist, + Vector3 center, + Vector3 direction, + float length, + float width, + Quaternion rotation) + : base(elbow, + wrist, + center, + direction, + length, + width, + BoneType.TYPE_METACARPAL, //ignored for arms + rotation) + { } /// /// Compare Arm object equality. @@ -73,6 +94,7 @@ namespace Leap /// /// @since 2.0.3 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector ElbowPosition { get @@ -90,6 +112,7 @@ namespace Leap /// /// @since 2.0.3 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector WristPosition { get diff --git a/ml_lme/vendor/LeapCSharp/Bone.cs b/ml_lme/vendor/LeapCSharp/Bone.cs index 6ba1b20..4e51fff 100644 --- a/ml_lme/vendor/LeapCSharp/Bone.cs +++ b/ml_lme/vendor/LeapCSharp/Bone.cs @@ -5,6 +5,7 @@ * http://www.apache.org/licenses/LICENSE-2.0, or another agreement * * between Ultraleap and you, your company or other organization. * ******************************************************************************/ +using UnityEngine; namespace Leap { @@ -26,7 +27,7 @@ namespace Leap [Serializable] public class Bone : IEquatable { - +#pragma warning disable 0618 /// /// Constructs a default invalid Bone object. /// @@ -41,6 +42,7 @@ namespace Leap /// Constructs a new Bone object. /// @since 3.0 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use Bone with Vector3s instead. If you believe that it needs to be kept, please open a discussion on the GitHub forum (https://github.com/ultraleap/UnityPlugin/discussions)")] public Bone(Vector prevJoint, Vector nextJoint, Vector center, @@ -60,6 +62,29 @@ namespace Leap Type = type; } + /// + /// Constructs a new Bone object. + /// @since 3.0 + /// + public Bone(Vector3 prevJoint, + Vector3 nextJoint, + Vector3 center, + Vector3 direction, + float length, + float width, + Bone.BoneType type, + Quaternion rotation) + { + PrevJoint = new Vector(prevJoint.x, prevJoint.y, prevJoint.z); + NextJoint = new Vector(nextJoint.x, nextJoint.y, nextJoint.z); + Center = new Vector(center.x, center.y, center.z); + Direction = new Vector(direction.x, direction.y, direction.z); + Rotation = new LeapQuaternion(rotation.x, rotation.y, rotation.z, rotation.w); + Length = length; + Width = width; + Type = type; + } + /// /// Compare Bone object equality. /// @@ -86,6 +111,7 @@ namespace Leap /// In anatomical terms, this is the proximal end of the bone. /// @since 2.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector PrevJoint; /// @@ -93,18 +119,22 @@ namespace Leap /// In anatomical terms, this is the distal end of the bone. /// @since 2.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] + public Vector NextJoint; /// /// The midpoint of the bone. /// @since 2.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector Center; /// /// The normalized direction of the bone from base to tip. /// @since 2.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector Direction; /// @@ -129,6 +159,7 @@ namespace Leap /// The orientation of this Bone as a Quaternion. /// @since 2.0 /// + [System.Obsolete("Its type will be changed from LeapQuaternion to UnityEngine.Quaternion")] public LeapQuaternion Rotation; /// @@ -179,5 +210,7 @@ namespace Leap TYPE_INTERMEDIATE = 2, TYPE_DISTAL = 3 } +#pragma warning restore 0618 + } } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/CSharpExtensions.cs b/ml_lme/vendor/LeapCSharp/CSharpExtensions.cs index ce9086d..8435d54 100644 --- a/ml_lme/vendor/LeapCSharp/CSharpExtensions.cs +++ b/ml_lme/vendor/LeapCSharp/CSharpExtensions.cs @@ -16,6 +16,14 @@ namespace Leap /// public static class CSharpExtensions { + public static class Constants + { + public const float PI = 3.1415926536f; + public const float DEG_TO_RAD = 0.0174532925f; + public const float RAD_TO_DEG = 57.295779513f; + public const float EPSILON = 1.192092896e-07f; + } + /// /// Compares whether two floating point numbers are within an epsilon value of each other. /// @since 3.0 diff --git a/ml_lme/vendor/LeapCSharp/Connection.cs b/ml_lme/vendor/LeapCSharp/Connection.cs index 3c54b75..2c17b05 100644 --- a/ml_lme/vendor/LeapCSharp/Connection.cs +++ b/ml_lme/vendor/LeapCSharp/Connection.cs @@ -567,7 +567,7 @@ namespace LeapInternal StructMarshal.PtrToStruct(new IntPtr(posPtr), out position); StructMarshal.PtrToStruct(new IntPtr(rotPtr), out orientation); - LeapTransform transform = new LeapTransform(position.ToLeapVector(), orientation.ToLeapQuaternion()); + LeapTransform transform = new LeapTransform(position.ToVector3(), orientation.ToQuaternion()); if (id == leftId) { leftTransform = transform; @@ -1189,6 +1189,7 @@ namespace LeapInternal /// /// Converts from image-space pixel coordinates to camera-space rectilinear coordinates /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Vector PixelToRectilinear(Image.CameraType camera, Vector pixel) { LEAP_VECTOR pixelStruct = new LEAP_VECTOR(pixel); @@ -1200,6 +1201,20 @@ namespace LeapInternal return new Vector(ray.x, ray.y, ray.z); } + /// + /// Converts from image-space pixel coordinates to camera-space rectilinear coordinates + /// + public UnityEngine.Vector3 PixelToRectilinear(Image.CameraType camera, UnityEngine.Vector3 pixel) + { + LEAP_VECTOR pixelStruct = new LEAP_VECTOR(pixel); + LEAP_VECTOR ray = LeapC.LeapPixelToRectilinear(_leapConnection, + (camera == Image.CameraType.LEFT ? + eLeapPerspectiveType.eLeapPerspectiveType_stereo_left : + eLeapPerspectiveType.eLeapPerspectiveType_stereo_right), + pixelStruct); + return new UnityEngine.Vector3(ray.x, ray.y, ray.z); + } + /// /// Converts from image-space pixel coordinates to camera-space rectilinear coordinates /// @@ -1207,6 +1222,7 @@ namespace LeapInternal /// /// @since 4.1 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Vector PixelToRectilinearEx(IntPtr deviceHandle, Image.CameraType camera, Image.CalibrationType calibType, Vector pixel) { @@ -1222,10 +1238,31 @@ namespace LeapInternal pixelStruct); return new Vector(ray.x, ray.y, ray.z); } + /// + /// Converts from image-space pixel coordinates to camera-space rectilinear coordinates + /// + /// Also allows specifying a specific device handle and calibration type. + /// + public UnityEngine.Vector3 PixelToRectilinearEx(IntPtr deviceHandle, + Image.CameraType camera, Image.CalibrationType calibType, UnityEngine.Vector3 pixel) + { + LEAP_VECTOR pixelStruct = new LEAP_VECTOR(pixel); + LEAP_VECTOR ray = LeapC.LeapPixelToRectilinearEx(_leapConnection, + deviceHandle, + (camera == Image.CameraType.LEFT ? + eLeapPerspectiveType.eLeapPerspectiveType_stereo_left : + eLeapPerspectiveType.eLeapPerspectiveType_stereo_right), + (calibType == Image.CalibrationType.INFRARED ? + eLeapCameraCalibrationType.eLeapCameraCalibrationType_infrared : + eLeapCameraCalibrationType.eLeapCameraCalibrationType_visual), + pixelStruct); + return new UnityEngine.Vector3(ray.x, ray.y, ray.z); + } /// /// Converts from camera-space rectilinear coordinates to image-space pixel coordinates /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Vector RectilinearToPixel(Image.CameraType camera, Vector ray) { LEAP_VECTOR rayStruct = new LEAP_VECTOR(ray); @@ -1236,6 +1273,19 @@ namespace LeapInternal rayStruct); return new Vector(pixel.x, pixel.y, pixel.z); } + /// + /// Converts from camera-space rectilinear coordinates to image-space pixel coordinates + /// + public UnityEngine.Vector3 RectilinearToPixel(Image.CameraType camera, UnityEngine.Vector3 ray) + { + LEAP_VECTOR rayStruct = new LEAP_VECTOR(ray); + LEAP_VECTOR pixel = LeapC.LeapRectilinearToPixel(_leapConnection, + (camera == Image.CameraType.LEFT ? + eLeapPerspectiveType.eLeapPerspectiveType_stereo_left : + eLeapPerspectiveType.eLeapPerspectiveType_stereo_right), + rayStruct); + return new UnityEngine.Vector3(pixel.x, pixel.y, pixel.z); + } public void TelemetryProfiling(ref LEAP_TELEMETRY_DATA telemetryData) { @@ -1272,7 +1322,9 @@ namespace LeapInternal pm.frameId = pmi.frame_id; pm.timestamp = pmi.timestamp; +#pragma warning disable 0618 pm.points = new Vector[nPoints]; +#pragma warning restore 0618 pm.ids = new UInt32[nPoints]; float[] points = new float[3 * nPoints]; diff --git a/ml_lme/vendor/LeapCSharp/Controller.cs b/ml_lme/vendor/LeapCSharp/Controller.cs index 4dfcfbb..64782e2 100644 --- a/ml_lme/vendor/LeapCSharp/Controller.cs +++ b/ml_lme/vendor/LeapCSharp/Controller.cs @@ -428,7 +428,7 @@ namespace Leap /// /// @since 1.0 /// - public Controller() : this(0, null, true) { } + public Controller() : this(0) { } /// /// Constructs a Controller object using the specified connection key. @@ -555,11 +555,30 @@ namespace Leap /// the change was accepted. /// @since 2.1.6 (5.4.4 for specific device) /// + [Obsolete("This method signature will be removed in a future update. Please use the equivalent method that does not take the serial number")] public void SetAndClearPolicy(PolicyFlag set, PolicyFlag clear, string deviceSerial = "", Device device = null) { _connection.SetAndClearPolicy(set, clear, device); } + /// + /// Requests setting and clearing policy flags on a specific device + /// + /// A request to change a policy is subject to user approval and a policy + /// can be changed by the user at any time (using the Leap Motion settings dialog). + /// The desired policy flags must be set every time an application runs. + /// + /// Policy changes are completed asynchronously and, because they are subject + /// to user approval or system compatibility checks, may not complete successfully. Call + /// Controller.IsPolicySet() after a suitable interval to test whether + /// the change was accepted. + /// @since 2.1.6 (5.4.4 for specific device) + /// + public void SetAndClearPolicy(PolicyFlag set, PolicyFlag clear, Device device = null) + { + _connection.SetAndClearPolicy(set, clear, device); + } + /// /// Requests setting a policy on a specific device /// diff --git a/ml_lme/vendor/LeapCSharp/CopyFromLeapCExtensions.cs b/ml_lme/vendor/LeapCSharp/CopyFromLeapCExtensions.cs index dd4618e..4c88bd8 100644 --- a/ml_lme/vendor/LeapCSharp/CopyFromLeapCExtensions.cs +++ b/ml_lme/vendor/LeapCSharp/CopyFromLeapCExtensions.cs @@ -9,7 +9,7 @@ namespace LeapInternal { using Leap; - +#pragma warning disable 0618 public static class CopyFromLeapCExtensions { @@ -139,4 +139,5 @@ namespace LeapInternal return bone; } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/CopyFromOtherExtensions.cs b/ml_lme/vendor/LeapCSharp/CopyFromOtherExtensions.cs index 514e835..318d247 100644 --- a/ml_lme/vendor/LeapCSharp/CopyFromOtherExtensions.cs +++ b/ml_lme/vendor/LeapCSharp/CopyFromOtherExtensions.cs @@ -8,7 +8,7 @@ namespace Leap { - +#pragma warning disable 0618 public static class CopyFromOtherExtensions { @@ -117,4 +117,5 @@ namespace Leap return bone; } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/Finger.cs b/ml_lme/vendor/LeapCSharp/Finger.cs index 275f375..5a110fe 100644 --- a/ml_lme/vendor/LeapCSharp/Finger.cs +++ b/ml_lme/vendor/LeapCSharp/Finger.cs @@ -6,10 +6,12 @@ * between Ultraleap and you, your company or other organization. * ******************************************************************************/ +using UnityEngine; + namespace Leap { using System; - +#pragma warning disable 0618 /// /// The Finger class represents a tracked finger. /// @@ -46,6 +48,7 @@ namespace Leap /// received from the service. /// @since 3.0 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Finger(long frameId, int handId, int fingerId, @@ -75,6 +78,42 @@ namespace Leap IsExtended = isExtended; TimeVisible = timeVisible; } + /// + /// Constructs a finger. + /// + /// Generally, you should not create your own finger objects. Such objects will not + /// have valid tracking data. Get valid finger objects from a hand in a frame + /// received from the service. + /// + public Finger(long frameId, + int handId, + int fingerId, + float timeVisible, + Vector3 tipPosition, + Vector3 direction, + float width, + float length, + bool isExtended, + FingerType type, + Bone metacarpal, + Bone proximal, + Bone intermediate, + Bone distal) + { + Type = type; + bones[0] = metacarpal; + bones[1] = proximal; + bones[2] = intermediate; + bones[3] = distal; + Id = (handId * 10) + fingerId; + HandId = handId; + TipPosition = ToVector(tipPosition); + Direction = ToVector(direction); + Width = width; + Length = length; + IsExtended = isExtended; + TimeVisible = timeVisible; + } /// /// The bone at a given bone index on this finger. @@ -125,6 +164,7 @@ namespace Leap /// The tip position of this Finger. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector TipPosition; /// @@ -132,6 +172,7 @@ namespace Leap /// as a unit vector pointing in the same direction as the tip. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector Direction; /// @@ -179,5 +220,13 @@ namespace Leap TYPE_PINKY = 4, TYPE_UNKNOWN = -1 } + + + [Obsolete("This will be removed in the next major version update")] + private Vector ToVector(Vector3 v) + { + return new Vector(v.x, v.y, v.z); + } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/Hand.cs b/ml_lme/vendor/LeapCSharp/Hand.cs index a5f9ba5..3f77c50 100644 --- a/ml_lme/vendor/LeapCSharp/Hand.cs +++ b/ml_lme/vendor/LeapCSharp/Hand.cs @@ -5,12 +5,13 @@ * http://www.apache.org/licenses/LICENSE-2.0, or another agreement * * between Ultraleap and you, your company or other organization. * ******************************************************************************/ +using UnityEngine; namespace Leap { using System; using System.Collections.Generic; - +#pragma warning disable 0618 /// /// The Hand class reports the physical characteristics of a detected hand. /// @@ -46,6 +47,7 @@ namespace Leap Fingers.Add(new Finger()); } + /// /// Constructs a hand. /// @@ -54,6 +56,7 @@ namespace Leap /// received from the service. /// @since 3.0 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 and Quaternion instead.")] public Hand(long frameID, int id, float confidence, @@ -94,6 +97,53 @@ namespace Leap Direction = direction; WristPosition = wristPosition; } + /// + /// Constructs a hand. + /// + /// Generally, you should not create your own Hand objects. Such objects will not + /// have valid tracking data. Get valid Hand objects from a frame + /// received from the service. + /// + public Hand(long frameID, + int id, + float confidence, + float grabStrength, + float grabAngle, + float pinchStrength, + float pinchDistance, + float palmWidth, + bool isLeft, + float timeVisible, + Arm arm, + List fingers, + Vector3 palmPosition, + Vector3 stabilizedPalmPosition, + Vector3 palmVelocity, + Vector3 palmNormal, + Quaternion palmOrientation, + Vector3 direction, + Vector3 wristPosition) + { + FrameId = frameID; + Id = id; + Confidence = confidence; + GrabStrength = grabStrength; + GrabAngle = grabAngle; + PinchStrength = pinchStrength; + PinchDistance = pinchDistance; + PalmWidth = palmWidth; + IsLeft = isLeft; + TimeVisible = timeVisible; + Arm = arm; + Fingers = fingers; + PalmPosition = ToVector(palmPosition); + StabilizedPalmPosition = ToVector(stabilizedPalmPosition); + PalmVelocity = ToVector(palmVelocity); + PalmNormal = ToVector(palmNormal); + Rotation = ToLeapQuaternion(palmOrientation); + Direction = ToVector(direction); + WristPosition = ToVector(wristPosition); + } /// /// The Finger object with the specified ID attached to this hand. @@ -171,12 +221,14 @@ namespace Leap /// The center position of the palm. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector PalmPosition; /// /// The rate of change of the palm position. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector PalmVelocity; /// @@ -190,6 +242,7 @@ namespace Leap /// respect to the horizontal plane. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector PalmNormal; /// @@ -202,6 +255,7 @@ namespace Leap /// respect to the horizontal plane. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector Direction; /// @@ -217,6 +271,7 @@ namespace Leap /// /// @since 3.1 /// + [System.Obsolete("Its type will be changed from LeapQuaternion to UnityEngine.Quaternion")] public LeapQuaternion Rotation; /// @@ -239,6 +294,7 @@ namespace Leap /// /// @since 3.0 /// + [System.Obsolete("This code will be removed in the next major version of the plugin. If you believe that it needs to be kept, please open a discussion on the GitHub forum (https://github.com/ultraleap/UnityPlugin/discussions)")] public float GrabAngle; /// @@ -276,16 +332,18 @@ namespace Leap /// primarily on the speed of movement. /// @since 1.0 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector StabilizedPalmPosition; /// /// The position of the wrist of this hand. /// @since 2.0.3 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector WristPosition; /// - /// The duration of time this Hand has been visible to the Leap Motion Controller. + /// The duration of time this Hand has been visible to the Leap Motion Controller, in seconds /// @since 1.0 /// public float TimeVisible; @@ -318,5 +376,20 @@ namespace Leap /// @since 2.0.3 /// public Arm Arm; + + + + [Obsolete("This will be removed in the next major version update")] + private Vector ToVector(Vector3 v) + { + return new Vector(v.x, v.y, v.z); + } + + [Obsolete("This will be removed in the next major version update")] + private LeapQuaternion ToLeapQuaternion(Quaternion q) + { + return new LeapQuaternion(q.x, q.y, q.z, q.w); + } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/Image.cs b/ml_lme/vendor/LeapCSharp/Image.cs index 035a224..ef1eb12 100644 --- a/ml_lme/vendor/LeapCSharp/Image.cs +++ b/ml_lme/vendor/LeapCSharp/Image.cs @@ -154,6 +154,11 @@ namespace Leap return imageData(camera).DistortionData.Data; } + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] + public Vector PixelToRectilinear(CameraType camera, Vector pixel) + { + return Connection.GetConnection().PixelToRectilinear(camera, pixel); + } /// /// Provides the corrected camera ray intercepting the specified point on the image. /// @@ -172,13 +177,17 @@ namespace Leap /// in between the time the image was received and the time this function is called. /// /// Note, this function was formerly named Rectify(). - /// @since 2.1.0 /// - public Vector PixelToRectilinear(CameraType camera, Vector pixel) + public UnityEngine.Vector3 PixelToRectilinear(CameraType camera, UnityEngine.Vector3 pixel) { return Connection.GetConnection().PixelToRectilinear(camera, pixel); } + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] + public Vector RectilinearToPixel(CameraType camera, Vector ray) + { + return Connection.GetConnection().RectilinearToPixel(camera, ray); + } /// /// Provides the point in the image corresponding to a ray projecting /// from the camera. @@ -202,9 +211,8 @@ namespace Leap /// in between the time the image was received and the time this function is called. /// /// Note, this function was formerly named Warp(). - /// @since 2.1.0 /// - public Vector RectilinearToPixel(CameraType camera, Vector ray) + public UnityEngine.Vector3 RectilinearToPixel(CameraType camera, UnityEngine.Vector3 ray) { return Connection.GetConnection().RectilinearToPixel(camera, ray); } diff --git a/ml_lme/vendor/LeapCSharp/LeapC.cs b/ml_lme/vendor/LeapCSharp/LeapC.cs index 9cc1827..386ac05 100644 --- a/ml_lme/vendor/LeapCSharp/LeapC.cs +++ b/ml_lme/vendor/LeapCSharp/LeapC.cs @@ -799,17 +799,29 @@ namespace LeapInternal public float y; public float z; + [System.Obsolete("This code will be removed in the next major version of the plugin. Use 'ToVector3()' instead.")] public Leap.Vector ToLeapVector() { return new Leap.Vector(x, y, z); } + public UnityEngine.Vector3 ToVector3() + { + return new UnityEngine.Vector3(x, y, z); + } + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one taking a Vector3 instead.")] public LEAP_VECTOR(Leap.Vector leap) { x = leap.x; y = leap.y; z = leap.z; } + public LEAP_VECTOR(UnityEngine.Vector3 vector) + { + x = vector.x; + y = vector.y; + z = vector.z; + } } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -820,11 +832,17 @@ namespace LeapInternal public float z; public float w; + [System.Obsolete("This code will be removed in the next major version of the plugin. Use 'ToQuaternion()' instead.")] public Leap.LeapQuaternion ToLeapQuaternion() { return new Leap.LeapQuaternion(x, y, z, w); } + public UnityEngine.Quaternion ToQuaternion() + { + return new UnityEngine.Quaternion(x, y, z, w); + } + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one taking a UnityEngine.Quaternion instead.")] public LEAP_QUATERNION(Leap.LeapQuaternion q) { x = q.x; @@ -832,6 +850,13 @@ namespace LeapInternal z = q.z; w = q.w; } + public LEAP_QUATERNION(UnityEngine.Quaternion q) + { + x = q.x; + y = q.y; + z = q.z; + w = q.w; + } } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/ml_lme/vendor/LeapCSharp/LeapQuaternion.cs b/ml_lme/vendor/LeapCSharp/LeapQuaternion.cs index 0ceac82..4802da5 100644 --- a/ml_lme/vendor/LeapCSharp/LeapQuaternion.cs +++ b/ml_lme/vendor/LeapCSharp/LeapQuaternion.cs @@ -14,6 +14,7 @@ namespace Leap /// The LeapQuaternion struct represents a rotation in three-dimensional space. /// @since 3.1.2 /// + [System.Obsolete("This code will be moved to a legacy package in the next major version of the plugin. Use Unity's Quaternion instead. If you believe that it needs to be kept in tracking, please open a discussion on the GitHub forum (https://github.com/ultraleap/UnityPlugin/discussions)")] [Serializable] public struct LeapQuaternion : IEquatable @@ -125,7 +126,7 @@ namespace Leap get { float denom = MagnitudeSquared; - if (denom <= Constants.EPSILON) + if (denom <= CSharpExtensions.Constants.EPSILON) { return Identity; } diff --git a/ml_lme/vendor/LeapCSharp/LeapTransform.cs b/ml_lme/vendor/LeapCSharp/LeapTransform.cs index f97c5ec..e7f121f 100644 --- a/ml_lme/vendor/LeapCSharp/LeapTransform.cs +++ b/ml_lme/vendor/LeapCSharp/LeapTransform.cs @@ -5,11 +5,12 @@ * http://www.apache.org/licenses/LICENSE-2.0, or another agreement * * between Ultraleap and you, your company or other organization. * ******************************************************************************/ +using UnityEngine; namespace Leap { using System; - +#pragma warning disable 0618 /// /// The LeapTransform class represents a transform in three dimensional space. /// @@ -22,15 +23,24 @@ namespace Leap /// Constructs a new transform from the specified translation and rotation. /// @since 3.1.2 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 and Quaternion instead.")] public LeapTransform(Vector translation, LeapQuaternion rotation) : this(translation, rotation, Vector.Ones) { } + /// + /// Constructs a new transform from the specified translation and rotation. + /// + public LeapTransform(Vector3 translation, Quaternion rotation) : + this(translation, rotation, Vector3.one) + { + } /// /// Constructs a new transform from the specified translation, rotation and scale. /// @since 3.1.2 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 and Quaternion instead.")] public LeapTransform(Vector translation, LeapQuaternion rotation, Vector scale) : this() { @@ -39,33 +49,81 @@ namespace Leap this.translation = translation; this.rotation = rotation; // Calls validateBasis } + /// + /// Constructs a new transform from the specified translation, rotation and scale. + /// + public LeapTransform(Vector3 translation, Quaternion rotation, Vector3 scale) : + this() + { + _scale = ToVector(scale); + // these are non-trival setters. + this.translation = ToVector(translation); + this.rotation = ToLeapQuaternion(rotation); // Calls validateBasis + } + + /// + /// Constructs a new Leap transform from a Unity Transform + /// + /// Unity Transform + public LeapTransform(Transform t) : this() + { + float MM_TO_M = 1e-3f; + _scale = new Vector(t.lossyScale.x * MM_TO_M, t.lossyScale.y * MM_TO_M, t.lossyScale.z * MM_TO_M); + this.translation = ToVector(t.position); + this.rotation = ToLeapQuaternion(t.rotation); + this.MirrorZ(); // Unity is left handed. + } /// /// Transforms the specified position vector, applying translation, rotation and scale. /// @since 3.1.2 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Vector TransformPoint(Vector point) { return _xBasisScaled * point.x + _yBasisScaled * point.y + _zBasisScaled * point.z + translation; } + /// + /// Transforms the specified position vector, applying translation, rotation and scale. + /// + public Vector3 TransformPoint(Vector3 point) + { + return ToVector3(_xBasisScaled * point.x + _yBasisScaled * point.y + _zBasisScaled * point.z + translation); + } /// /// Transforms the specified direction vector, applying rotation only. /// @since 3.1.2 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Vector TransformDirection(Vector direction) { return _xBasis * direction.x + _yBasis * direction.y + _zBasis * direction.z; } + /// + /// Transforms the specified direction vector, applying rotation only. + /// + public Vector3 TransformDirection(Vector3 direction) + { + return ToVector3(_xBasis * direction.x + _yBasis * direction.y + _zBasis * direction.z); + } /// /// Transforms the specified velocity vector, applying rotation and scale. /// @since 3.1.2 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with Vector3 instead.")] public Vector TransformVelocity(Vector velocity) { return _xBasisScaled * velocity.x + _yBasisScaled * velocity.y + _zBasisScaled * velocity.z; } + /// + /// Transforms the specified velocity vector, applying rotation and scale. + /// + public Vector3 TransformVelocity(Vector3 velocity) + { + return ToVector3(_xBasisScaled * velocity.x + _yBasisScaled * velocity.y + _zBasisScaled * velocity.z); + } /// /// Transforms the specified quaternion. @@ -78,6 +136,7 @@ namespace Leap /// /// @since 3.1.2 /// + [System.Obsolete("This signature will be removed in the next major version of the plugin. Use the one with UnityEngine.Quaternion instead.")] public LeapQuaternion TransformQuaternion(LeapQuaternion rhs) { if (_quaternionDirty) @@ -94,6 +153,31 @@ namespace Leap LeapQuaternion t = _quaternion.Multiply(rhs); return t; } + /// + /// Transforms the specified quaternion. + /// Multiplies the quaternion representing the rotational part of this transform by the specified + /// quaternion. + /// + /// **Important:** Modifying the basis vectors of this transform directly leaves the underlying quaternion in + /// an indeterminate state. Neither this function nor the LeapTransform.rotation quaternion can be used after + /// the basis vectors are set. + /// + public Quaternion TransformQuaternion(Quaternion rhs) + { + if (_quaternionDirty) + throw new InvalidOperationException("Calling TransformQuaternion after Basis vectors have been modified."); + + if (_flip) + { + // Mirror the axis of rotation across the flip axis. + rhs.x *= _flipAxes.x; + rhs.y *= _flipAxes.y; + rhs.z *= _flipAxes.z; + } + + Quaternion t = ToQuaternion(_quaternion) * rhs; + return t; + } /// /// Mirrors this transform's rotation and scale across the x-axis. Translation is not affected. @@ -132,6 +216,7 @@ namespace Leap /// /// @since 3.1.2 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector xBasis { get { return _xBasis; } @@ -152,6 +237,7 @@ namespace Leap /// /// @since 3.1.2 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector yBasis { get { return _yBasis; } @@ -172,6 +258,7 @@ namespace Leap /// /// @since 3.1.2 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector zBasis { get { return _zBasis; } @@ -187,6 +274,7 @@ namespace Leap /// The translation component of the transform. /// @since 3.1.2 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector translation { get { return _translation; } @@ -201,6 +289,7 @@ namespace Leap /// Scale is kept separate from translation. /// @since 3.1.2 /// + [System.Obsolete("Its type will be changed from Vector to Vector3")] public Vector scale { get { return _scale; } @@ -222,6 +311,7 @@ namespace Leap /// /// @since 3.1.2 /// + [System.Obsolete("Its type will be changed from LeapQuaternion to UnityEngine.Quaternion")] public LeapQuaternion rotation { get @@ -234,7 +324,7 @@ namespace Leap { _quaternion = value; - float d = value.MagnitudeSquared; + float d = value.x * value.x + value.y * value.y + value.z * value.z + value.w * value.w; float s = 2.0f / d; float xs = value.x * s, ys = value.y * s, zs = value.z * s; float wx = value.w * xs, wy = value.w * ys, wz = value.w * zs; @@ -259,19 +349,54 @@ namespace Leap /// The identity transform. /// @since 3.1.2 /// - public static readonly LeapTransform Identity = new LeapTransform(Vector.Zero, LeapQuaternion.Identity, Vector.Ones); + public static readonly LeapTransform Identity = new LeapTransform(Vector3.zero, Quaternion.identity, Vector3.one); + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _translation; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _scale; + [System.Obsolete("Its type will be changed from LeapQuaternion to UnityEngine.Quaternion")] private LeapQuaternion _quaternion; private bool _quaternionDirty; private bool _flip; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _flipAxes; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _xBasis; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _yBasis; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _zBasis; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _xBasisScaled; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _yBasisScaled; + [System.Obsolete("Its type will be changed from Vector to Vector3")] private Vector _zBasisScaled; + + [Obsolete("This will be removed in the next major version update")] + private Vector ToVector(Vector3 v) + { + return new Vector(v.x, v.y, v.z); + } + + [Obsolete("This will be removed in the next major version update")] + private Vector3 ToVector3(Vector v) + { + return new Vector3(v.x, v.y, v.z); + } + + [Obsolete("This will be removed in the next major version update")] + private LeapQuaternion ToLeapQuaternion(Quaternion q) + { + return new LeapQuaternion(q.x, q.y, q.z, q.w); + } + + [Obsolete("This will be removed in the next major version update")] + private Quaternion ToQuaternion(LeapQuaternion q) + { + return new Quaternion(q.x, q.y, q.z, q.w); + } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/Matrix.cs b/ml_lme/vendor/LeapCSharp/Matrix.cs index aca90b3..ac09e9e 100644 --- a/ml_lme/vendor/LeapCSharp/Matrix.cs +++ b/ml_lme/vendor/LeapCSharp/Matrix.cs @@ -21,6 +21,7 @@ namespace Leap /// the * operator. /// @since 1.0 /// + [System.Obsolete("This code will be moved to a legacy package in the next major version of the plugin. If you believe that it needs to be kept in tracking, please open a discussion on the GitHub forum (https://github.com/ultraleap/UnityPlugin/discussions)")] public struct Matrix { diff --git a/ml_lme/vendor/LeapCSharp/PointMapping.cs b/ml_lme/vendor/LeapCSharp/PointMapping.cs index 77e3aa1..4b30417 100644 --- a/ml_lme/vendor/LeapCSharp/PointMapping.cs +++ b/ml_lme/vendor/LeapCSharp/PointMapping.cs @@ -8,7 +8,7 @@ namespace Leap { - +#pragma warning disable 0618 public struct PointMapping { public long frameId; @@ -16,4 +16,5 @@ namespace Leap public Vector[] points; public uint[] ids; } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/StructMarshal.cs b/ml_lme/vendor/LeapCSharp/StructMarshal.cs index 6ad9444..31ac9e9 100644 --- a/ml_lme/vendor/LeapCSharp/StructMarshal.cs +++ b/ml_lme/vendor/LeapCSharp/StructMarshal.cs @@ -53,13 +53,9 @@ namespace LeapInternal public static void PtrToStruct(IntPtr ptr, out T t) { #if ENABLE_IL2CPP -#if UNITY_2018_1_OR_NEWER unsafe { Unity.Collections.LowLevel.Unsafe.UnsafeUtility.CopyPtrToStructure((void*)ptr, out t); } -#else -#error UnityModules Only supports IL2CPP on versions of Unity 2018.1 or greater. -#endif #else if (_container == null) { diff --git a/ml_lme/vendor/LeapCSharp/TransformExtensions.cs b/ml_lme/vendor/LeapCSharp/TransformExtensions.cs index bcd4a2b..367ae4f 100644 --- a/ml_lme/vendor/LeapCSharp/TransformExtensions.cs +++ b/ml_lme/vendor/LeapCSharp/TransformExtensions.cs @@ -6,10 +6,12 @@ * between Ultraleap and you, your company or other organization. * ******************************************************************************/ +using UnityEngine; + namespace Leap { using System; - +#pragma warning disable 0618 public static class TransformExtensions { @@ -173,4 +175,5 @@ namespace Leap return new Bone().CopyFrom(bone).Transform(transform); } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/ml_lme/vendor/LeapCSharp/Vector.cs b/ml_lme/vendor/LeapCSharp/Vector.cs index faabbd5..7096505 100644 --- a/ml_lme/vendor/LeapCSharp/Vector.cs +++ b/ml_lme/vendor/LeapCSharp/Vector.cs @@ -13,6 +13,7 @@ namespace Leap /// /// Constants used in Leap Motion math functions. /// + [System.Obsolete("This code will be moved to Leap.CSharpExtensions.Constants in the next major version of the plugin.")] public static class Constants { public const float PI = 3.1415926536f; @@ -34,6 +35,7 @@ namespace Leap /// The z-axis has positive values increasing away from the computer screen. /// @since 1.0 /// + [System.Obsolete("This code will be moved to a legacy package in the next major version of the plugin. Use Unity's Vector3 instead. If you believe that it needs to be kept in tracking, please open a discussion on the GitHub forum (https://github.com/ultraleap/UnityPlugin/discussions)")] [Serializable] public struct Vector : IEquatable { @@ -135,7 +137,7 @@ namespace Leap public float AngleTo(Vector other) { float denom = MagnitudeSquared * other.MagnitudeSquared; - if (denom <= Constants.EPSILON) + if (denom <= CSharpExtensions.Constants.EPSILON) { return 0.0f; } @@ -146,7 +148,7 @@ namespace Leap } else if (val <= -1.0f) { - return Constants.PI; + return CSharpExtensions.Constants.PI; } return (float)Math.Acos(val); } @@ -335,7 +337,7 @@ namespace Leap get { float denom = MagnitudeSquared; - if (denom <= Constants.EPSILON) + if (denom <= CSharpExtensions.Constants.EPSILON) { return Zero; }