diff --git a/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/AggregationProviderConfidenceInterpolation.cs b/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/AggregationProviderConfidenceInterpolation.cs index dbb5ce4aaf..eaaa3d4cd8 100644 --- a/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/AggregationProviderConfidenceInterpolation.cs +++ b/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/AggregationProviderConfidenceInterpolation.cs @@ -570,16 +570,16 @@ float[] Confidence_RelativeJointRot(float[] confidences, Transform deviceOrigin, confidences = new float[VectorHand.NUM_JOINT_POSITIONS]; } - foreach (var finger in hand.Fingers) + foreach (var finger in hand.fingers) { for (int bone_idx = 0; bone_idx < 4; bone_idx++) { int key = (int)finger.Type * 4 + bone_idx; - Vector3 jointPos = finger.Bone((Bone.BoneType)bone_idx).NextJoint; + Vector3 jointPos = finger.GetBone((Bone.BoneType)bone_idx).NextJoint; Vector3 jointNormalVector = new Vector3(); - if ((int)finger.Type == 0) jointNormalVector = finger.Bone((Bone.BoneType)bone_idx).Rotation * Vector3.right; - else jointNormalVector = finger.Bone((Bone.BoneType)bone_idx).Rotation * Vector3.up * -1; + if ((int)finger.Type == 0) jointNormalVector = finger.GetBone((Bone.BoneType)bone_idx).Rotation * Vector3.right; + else jointNormalVector = finger.GetBone((Bone.BoneType)bone_idx).Rotation * Vector3.up * -1; float angle = Vector3.Angle(jointPos - deviceOrigin.position, jointNormalVector); @@ -604,13 +604,13 @@ float[] Confidence_relativeJointRotToPalmRot(float[] confidences, Transform devi confidences = new float[VectorHand.NUM_JOINT_POSITIONS]; } - foreach (var finger in hand.Fingers) + foreach (var finger in hand.fingers) { for (int bone_idx = 0; bone_idx < 4; bone_idx++) { int key = (int)finger.Type * 4 + bone_idx; - Vector3 jointNormalVector = finger.Bone((Bone.BoneType)bone_idx).Rotation * Vector3.up * -1; + Vector3 jointNormalVector = finger.GetBone((Bone.BoneType)bone_idx).Rotation * Vector3.up * -1; float angle = Vector3.Angle(hand.PalmNormal, jointNormalVector); diff --git a/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/JointOcclusion.cs b/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/JointOcclusion.cs index acb2049ea9..c6f996d032 100644 --- a/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/JointOcclusion.cs +++ b/Packages/Tracking Preview/AggregationProviders/Runtime/Scripts/JointOcclusion.cs @@ -145,7 +145,7 @@ public float[] Confidence_JointOcclusion(float[] confidences, Transform deviceOr // and how many pixels of a joint would be seen if the joint was not occluded at all (in optimalPixelsCount) int[] pixelsSeenCount = new int[confidences.Length]; int[] optimalPixelsCount = new int[confidences.Length]; - foreach (var finger in hand.Fingers) + foreach (var finger in hand.fingers) { for (int j = 0; j < 4; j++) { @@ -158,7 +158,7 @@ public float[] Confidence_JointOcclusion(float[] confidences, Transform deviceOr // get the joint position from the given hand and use it to calculate the screen position of the joint's center and // a point on the outside border of the joint (both in pixel coordinates) - Vector3 jointPos = finger.Bone((Leap.Bone.BoneType)j).NextJoint; + Vector3 jointPos = finger.GetBone((Leap.Bone.BoneType)j).NextJoint; Vector3 screenPosCenter = cam.WorldToScreenPoint(jointPos); Vector3 screenPosSphereOutside = cam.WorldToScreenPoint(jointPos + cam.transform.right * jointRadius); diff --git a/Packages/Tracking Preview/Examples~/Aggregation Provider Examples.meta b/Packages/Tracking Preview/Examples~/Aggregation Provider Examples.meta deleted file mode 100644 index ec5b905469..0000000000 --- a/Packages/Tracking Preview/Examples~/Aggregation Provider Examples.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b6f3d2eda844ed84096a78333741be7b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Examples~/Aggregation Provider Examples/Scripts/Utility/MultideviceAlignment.cs b/Packages/Tracking Preview/Examples~/Aggregation Provider Examples/Scripts/Utility/MultideviceAlignment.cs index 8293897137..00bbda7fb2 100644 --- a/Packages/Tracking Preview/Examples~/Aggregation Provider Examples/Scripts/Utility/MultideviceAlignment.cs +++ b/Packages/Tracking Preview/Examples~/Aggregation Provider Examples/Scripts/Utility/MultideviceAlignment.cs @@ -53,8 +53,8 @@ void Update() { for (int k = 0; k < 4; k++) { - sourceHandPoints.Add(sourceHand.Fingers[j].bones[k].Center); - targetHandPoints.Add(targetHand.Fingers[j].bones[k].Center); + sourceHandPoints.Add(sourceHand.fingers[j].bones[k].Center); + targetHandPoints.Add(targetHand.fingers[j].bones[k].Center); } } diff --git a/Packages/Tracking Preview/Examples~/Example Assets.meta b/Packages/Tracking Preview/Examples~/Example Assets.meta deleted file mode 100644 index 2e30051166..0000000000 --- a/Packages/Tracking Preview/Examples~/Example Assets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b13840bd5fb87184487352f9718d7f93 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Examples~/Hand Recorder.meta b/Packages/Tracking Preview/Examples~/Hand Recorder.meta deleted file mode 100644 index 487fb8cc86..0000000000 --- a/Packages/Tracking Preview/Examples~/Hand Recorder.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b7610165ec007a04cbbe3c5acc21f713 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Examples~/HandRays.meta b/Packages/Tracking Preview/Examples~/HandRays.meta deleted file mode 100644 index 03604d151e..0000000000 --- a/Packages/Tracking Preview/Examples~/HandRays.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 47cf4c61e288a4247984d2128022659e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Examples~/Locomotion.meta b/Packages/Tracking Preview/Examples~/Locomotion.meta deleted file mode 100644 index 80dd7da465..0000000000 --- a/Packages/Tracking Preview/Examples~/Locomotion.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cdfd0b079d1af24419d9ada8bcb41f31 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Examples~/UI Input Examples.meta b/Packages/Tracking Preview/Examples~/UI Input Examples.meta deleted file mode 100644 index 6b1d25200d..0000000000 --- a/Packages/Tracking Preview/Examples~/UI Input Examples.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d1a7a5683f4e8b94abdcb537669c16d0 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Examples~/XRControllerSupport.meta b/Packages/Tracking Preview/Examples~/XRControllerSupport.meta deleted file mode 100644 index 45a14aa0f8..0000000000 --- a/Packages/Tracking Preview/Examples~/XRControllerSupport.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: de747ab787879244f844ca6ff5b0e182 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tracking Preview/Locomotion/Runtime/Scripts/Teleportation/Teleport Action/Jump Gem Teleport/JumpGem.cs b/Packages/Tracking Preview/Locomotion/Runtime/Scripts/Teleportation/Teleport Action/Jump Gem Teleport/JumpGem.cs index 7d08fe97d7..f98372e6a8 100644 --- a/Packages/Tracking Preview/Locomotion/Runtime/Scripts/Teleportation/Teleport Action/Jump Gem Teleport/JumpGem.cs +++ b/Packages/Tracking Preview/Locomotion/Runtime/Scripts/Teleportation/Teleport Action/Jump Gem Teleport/JumpGem.cs @@ -448,7 +448,7 @@ private void PositionGem() if (_pinchStartTimeCurrent > 0) { _pinchItem.position = Vector3.Lerp(_pinchStartPosition, - Vector3.Lerp(_pinchedHand.Fingers[0].TipPosition, _pinchedHand.Fingers[1].TipPosition, 0.5f), + Vector3.Lerp(_pinchedHand.fingers[0].TipPosition, _pinchedHand.fingers[1].TipPosition, 0.5f), Mathf.InverseLerp(_pinchStartTime, 0, _pinchStartTimeCurrent)); _pinchItem.rotation = Quaternion.Lerp(_pinchStartRotation, _rayRotation, @@ -456,7 +456,7 @@ private void PositionGem() } else { - _pinchItem.position = Vector3.Lerp(_pinchedHand.Fingers[0].TipPosition, _pinchedHand.Fingers[1].TipPosition, 0.5f); + _pinchItem.position = Vector3.Lerp(_pinchedHand.fingers[0].TipPosition, _pinchedHand.fingers[1].TipPosition, 0.5f); _pinchItem.rotation = _rayRotation; } } diff --git a/Packages/Tracking Preview/UI Input/Runtime/Scripts/PointerElement.cs b/Packages/Tracking Preview/UI Input/Runtime/Scripts/PointerElement.cs index 6cd4098433..933cf5bf8e 100644 --- a/Packages/Tracking Preview/UI Input/Runtime/Scripts/PointerElement.cs +++ b/Packages/Tracking Preview/UI Input/Runtime/Scripts/PointerElement.cs @@ -163,8 +163,8 @@ private void Start() /// private float DistanceOfTipToPointer(Hand hand) { - var tipPosition = hand.Fingers[(int)Finger.FingerType.TYPE_INDEX] - .Bone(Bone.BoneType.TYPE_DISTAL).NextJoint; + var tipPosition = hand.fingers[(int)Finger.FingerType.INDEX] + .GetBone(Bone.BoneType.DISTAL).NextJoint; var pointerTransform = transform; return -pointerTransform.transform.InverseTransformPoint(tipPosition).z * pointerTransform.transform.lossyScale.z - module.TactilePadding; @@ -760,27 +760,27 @@ private bool GetLookPointerEventData(Hand hand, Vector3 origin, bool forceTipRay tipRaycast = true; var farthest = 0f; - pointerPosition = hand.GetIndex().TipPosition; + pointerPosition = hand.Index.TipPosition; for (var i = 1; i < 3; i++) { var fingerDistance = Vector3.Distance(mainCamera.transform.position, - hand.Fingers[i].TipPosition); + hand.fingers[i].TipPosition); var fingerExtension = Mathf.Clamp01(Vector3.Dot( - hand.Fingers[i].Direction, + hand.fingers[i].Direction, leapDataProvider.CurrentFrame.Hands[0].Direction)) / 1.5f; if (fingerDistance > farthest && fingerExtension > 0.5f) { farthest = fingerDistance; - pointerPosition = hand.Fingers[i].TipPosition; + pointerPosition = hand.fingers[i].TipPosition; } } } else { //Raycast through the knuckle of the finger - pointerPosition = mainCamera.transform.position - origin + hand.Fingers[(int)Finger.FingerType.TYPE_INDEX].Bone(Bone.BoneType.TYPE_METACARPAL).Center; + pointerPosition = mainCamera.transform.position - origin + hand.fingers[(int)Finger.FingerType.INDEX].GetBone(Bone.BoneType.METACARPAL).Center; } //Set the Raycast Direction and Delta diff --git a/Packages/Tracking Preview/XRControllerSupport/Runtime/Scripts/ControllerPostProcess/ControllerHand.cs b/Packages/Tracking Preview/XRControllerSupport/Runtime/Scripts/ControllerPostProcess/ControllerHand.cs index 9dc6d51977..d8e51eda57 100644 --- a/Packages/Tracking Preview/XRControllerSupport/Runtime/Scripts/ControllerPostProcess/ControllerHand.cs +++ b/Packages/Tracking Preview/XRControllerSupport/Runtime/Scripts/ControllerPostProcess/ControllerHand.cs @@ -441,15 +441,15 @@ private Hand GenerateControllerHand() SetFingerSizes(ref h, 0.013f); // Thumb - RotateFinger(h.Fingers[0], this.Thumb); + RotateFinger(h.fingers[0], this.Thumb); // index Finger - RotateFinger(h.Fingers[1], this.IndexFinger); + RotateFinger(h.fingers[1], this.IndexFinger); // Grip Fingers - RotateFinger(h.Fingers[2], this.MiddleFinger); - RotateFinger(h.Fingers[3], this.RingFinger); - RotateFinger(h.Fingers[4], this.PinkyFinger); + RotateFinger(h.fingers[2], this.MiddleFinger); + RotateFinger(h.fingers[3], this.RingFinger); + RotateFinger(h.fingers[4], this.PinkyFinger); h.Transform(_currentPosition, _currentRotation); @@ -469,11 +469,11 @@ private Hand GenerateControllerHand() private void SetFingerSizes(ref Hand hand, float boneWidth) { - for (int i = 0; i < hand.Fingers.Count; i++) + for (int i = 0; i < hand.fingers.Length; i++) { - for (int j = 0; j < hand.Fingers[i].bones.Length; j++) + for (int j = 0; j < hand.fingers[i].bones.Length; j++) { - hand.Fingers[i].bones[j].Width = boneWidth; + hand.fingers[i].bones[j].Width = boneWidth; } } } diff --git a/Packages/Tracking/CHANGELOG.md b/Packages/Tracking/CHANGELOG.md index 386e96d589..4b74e3c51d 100644 --- a/Packages/Tracking/CHANGELOG.md +++ b/Packages/Tracking/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved XRHands support for Meta Aim Input Actions - XRLeapProviderManager renamed LEAP_DIRECT to ULTRALEAP +- Accessors for Hand.Finger, Hand.Bone and Finger.Bone +- Renamed BoneType enum entries to remove redundancies ### Fixed - Issue with the method signature for LeapPixelToRectilinearEx diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Arm.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Arm.cs index 7f89f59a22..a6e00d2878 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Arm.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Arm.cs @@ -42,7 +42,7 @@ public class Arm : Bone, IEquatable direction, length, width, - BoneType.TYPE_METACARPAL, //ignored for arms + BoneType.METACARPAL, //ignored for arms rotation) { } diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Bone.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Bone.cs index 2922bf5e80..dba51c1cdf 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Bone.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Bone.cs @@ -34,7 +34,7 @@ public class Bone : IEquatable /// public Bone() { - Type = BoneType.TYPE_INVALID; + Type = BoneType.UNKNOWN; } /// @@ -185,11 +185,11 @@ public LeapTransform Basis /// public enum BoneType { - TYPE_INVALID = -1, - TYPE_METACARPAL = 0, - TYPE_PROXIMAL = 1, - TYPE_INTERMEDIATE = 2, - TYPE_DISTAL = 3 + UNKNOWN = -1, + METACARPAL = 0, + PROXIMAL = 1, + INTERMEDIATE = 2, + DISTAL = 3 } } } \ No newline at end of file diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromLeapCExtensions.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromLeapCExtensions.cs index 82d352507f..ae5df8123e 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromLeapCExtensions.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromLeapCExtensions.cs @@ -75,7 +75,7 @@ private static Hand CopyFrom(this Hand hand, ref LEAP_HAND leapHand, long frameI hand.FrameId = frameId; hand.Id = (int)leapHand.id; - hand.Arm.CopyFrom(leapHand.arm, Bone.BoneType.TYPE_INVALID); + hand.Arm.CopyFrom(leapHand.arm, Bone.BoneType.UNKNOWN); hand.Confidence = leapHand.confidence; hand.GrabStrength = leapHand.grab_strength; @@ -92,11 +92,11 @@ private static Hand CopyFrom(this Hand hand, ref LEAP_HAND leapHand, long frameI hand.Direction = leapHand.palm.direction.ToVector3(); hand.WristPosition = hand.Arm.NextJoint; - hand.Fingers[0].CopyFrom(leapHand.thumb, Leap.Finger.FingerType.TYPE_THUMB, hand.Id, hand.TimeVisible); - hand.Fingers[1].CopyFrom(leapHand.index, Leap.Finger.FingerType.TYPE_INDEX, hand.Id, hand.TimeVisible); - hand.Fingers[2].CopyFrom(leapHand.middle, Leap.Finger.FingerType.TYPE_MIDDLE, hand.Id, hand.TimeVisible); - hand.Fingers[3].CopyFrom(leapHand.ring, Leap.Finger.FingerType.TYPE_RING, hand.Id, hand.TimeVisible); - hand.Fingers[4].CopyFrom(leapHand.pinky, Leap.Finger.FingerType.TYPE_PINKY, hand.Id, hand.TimeVisible); + hand.fingers[0].CopyFrom(leapHand.thumb, Leap.Finger.FingerType.THUMB, hand.Id, hand.TimeVisible); + hand.fingers[1].CopyFrom(leapHand.index, Leap.Finger.FingerType.INDEX, hand.Id, hand.TimeVisible); + hand.fingers[2].CopyFrom(leapHand.middle, Leap.Finger.FingerType.MIDDLE, hand.Id, hand.TimeVisible); + hand.fingers[3].CopyFrom(leapHand.ring, Leap.Finger.FingerType.RING, hand.Id, hand.TimeVisible); + hand.fingers[4].CopyFrom(leapHand.pinky, Leap.Finger.FingerType.PINKY, hand.Id, hand.TimeVisible); hand.TransformToUnityUnits(); @@ -123,10 +123,10 @@ private static Finger CopyFrom(this Finger finger, LEAP_DIGIT leapBone, Finger.F Bone intermediate = finger.bones[2]; Bone distal = finger.bones[3]; - metacarpal.CopyFrom(leapBone.metacarpal, Leap.Bone.BoneType.TYPE_METACARPAL); - proximal.CopyFrom(leapBone.proximal, Leap.Bone.BoneType.TYPE_PROXIMAL); - intermediate.CopyFrom(leapBone.intermediate, Leap.Bone.BoneType.TYPE_INTERMEDIATE); - distal.CopyFrom(leapBone.distal, Leap.Bone.BoneType.TYPE_DISTAL); + metacarpal.CopyFrom(leapBone.metacarpal, Leap.Bone.BoneType.METACARPAL); + proximal.CopyFrom(leapBone.proximal, Leap.Bone.BoneType.PROXIMAL); + intermediate.CopyFrom(leapBone.intermediate, Leap.Bone.BoneType.INTERMEDIATE); + distal.CopyFrom(leapBone.distal, Leap.Bone.BoneType.DISTAL); finger.TipPosition = distal.NextJoint; finger.Direction = intermediate.Direction; diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromOtherExtensions.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromOtherExtensions.cs index a1eed4904b..2e0a9bce00 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromOtherExtensions.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/CopyFromOtherExtensions.cs @@ -62,7 +62,7 @@ public static Hand CopyFrom(this Hand hand, Hand source) for (int i = 5; i-- != 0;) { - hand.Fingers[i].CopyFrom(source.Fingers[i]); + hand.fingers[i].CopyFrom(source.fingers[i]); } return hand; diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Finger.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Finger.cs index ccdad62074..e217d2845f 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Finger.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Finger.cs @@ -29,6 +29,11 @@ public class Finger /// public Bone[] bones = new Bone[4]; + public Bone Metacarpal => bones[0]; + public Bone Proximal => bones[1]; + public Bone Intermediate => bones[2]; + public Bone Distal => bones[3]; + /// /// Constructs a finger. /// @@ -82,15 +87,6 @@ public Finger() TimeVisible = timeVisible; } - /// - /// The bone at a given bone index on this finger. - /// @since 2.0 - /// - public Bone Bone(Bone.BoneType boneIx) - { - return bones[(int)boneIx]; - } - /// /// A string containing a brief, human readable description of the Finger object. /// @since 1.0 @@ -178,12 +174,12 @@ public override string ToString() /// public enum FingerType { - TYPE_THUMB = 0, - TYPE_INDEX = 1, - TYPE_MIDDLE = 2, - TYPE_RING = 3, - TYPE_PINKY = 4, - TYPE_UNKNOWN = -1 + THUMB = 0, + INDEX = 1, + MIDDLE = 2, + RING = 3, + PINKY = 4, + UNKNOWN = -1 } } } \ No newline at end of file diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Hand.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Hand.cs index e7c036d2c9..4d57ce98ed 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Hand.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Hand.cs @@ -26,7 +26,6 @@ namespace Leap [Serializable] public class Hand : IEquatable { - /// /// Constructs a Hand object. /// @@ -38,12 +37,11 @@ public class Hand : IEquatable public Hand() { Arm = new Arm(); - Fingers = new List(5); - Fingers.Add(new Finger()); - Fingers.Add(new Finger()); - Fingers.Add(new Finger()); - Fingers.Add(new Finger()); - Fingers.Add(new Finger()); + fingers[0] = new Finger(); + fingers[1] = new Finger(); + fingers[2] = new Finger(); + fingers[3] = new Finger(); + fingers[4] = new Finger(); } /// @@ -63,7 +61,7 @@ public Hand() bool isLeft, float timeVisible, Arm arm, - List fingers, + Finger[] fingers, Vector3 palmPosition, Vector3 stabilizedPalmPosition, Vector3 palmVelocity, @@ -82,7 +80,7 @@ public Hand() IsLeft = isLeft; TimeVisible = timeVisible; Arm = arm; - Fingers = fingers; + this.fingers = fingers; PalmPosition = palmPosition; StabilizedPalmPosition = stabilizedPalmPosition; PalmVelocity = palmVelocity; @@ -92,31 +90,6 @@ public Hand() WristPosition = wristPosition; } - /// - /// The Finger object with the specified ID attached to this hand. - /// - /// Use the Hand.Finger() function to retrieve a Finger object attached to - /// this hand using an ID value obtained from a previous frame. - /// - /// Note that ID values persist across frames, but only until tracking of a - /// particular object is lost. If tracking of a hand is lost and subsequently - /// regained, the new Finger object representing that finger may have a - /// different ID than that representing the finger in an earlier frame. - /// - /// @since 1.0 - /// - public Finger Finger(int id) - { - for (int i = Fingers.Count; i-- != 0;) - { - if (Fingers[i].Id == id) - { - return Fingers[i]; - } - } - return null; - } - /// /// Compare Hand object equality. /// @@ -162,7 +135,13 @@ public override string ToString() /// this hand, given in order from thumb to pinky. The list cannot be empty. /// @since 1.0 /// - public List Fingers; + public Finger[] fingers = new Finger[5]; + + public Finger Thumb => fingers[0]; + public Finger Index => fingers[1]; + public Finger Middle => fingers[2]; + public Finger Ring => fingers[3]; + public Finger Pinky => fingers[4]; /// /// The center position of the palm. diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/TransformExtensions.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/TransformExtensions.cs index 90d97c94da..fa5d416437 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/TransformExtensions.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/TransformExtensions.cs @@ -73,7 +73,7 @@ public static Hand Transform(this Hand hand, LeapTransform transform) for (int i = 5; i-- != 0;) { - hand.Fingers[i].Transform(transform); + hand.fingers[i].Transform(transform); } return hand; diff --git a/Packages/Tracking/Core/Runtime/Scripts/Attachments/AttachmentPointBehaviour.cs b/Packages/Tracking/Core/Runtime/Scripts/Attachments/AttachmentPointBehaviour.cs index d98c172607..498c608dfb 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Attachments/AttachmentPointBehaviour.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Attachments/AttachmentPointBehaviour.cs @@ -102,88 +102,88 @@ public static void GetLeapHandPointData(Leap.Hand hand, AttachmentPointFlags sin break; case AttachmentPointFlags.ThumbProximalJoint: - position = hand.Fingers[0].bones[1].NextJoint; - rotation = hand.Fingers[0].bones[2].Rotation; + position = hand.fingers[0].bones[1].NextJoint; + rotation = hand.fingers[0].bones[2].Rotation; break; case AttachmentPointFlags.ThumbDistalJoint: - position = hand.Fingers[0].bones[2].NextJoint; - rotation = hand.Fingers[0].bones[3].Rotation; + position = hand.fingers[0].bones[2].NextJoint; + rotation = hand.fingers[0].bones[3].Rotation; break; case AttachmentPointFlags.ThumbTip: - position = hand.Fingers[0].bones[3].NextJoint; - rotation = hand.Fingers[0].bones[3].Rotation; + position = hand.fingers[0].bones[3].NextJoint; + rotation = hand.fingers[0].bones[3].Rotation; break; case AttachmentPointFlags.IndexKnuckle: - position = hand.Fingers[1].bones[0].NextJoint; - rotation = hand.Fingers[1].bones[1].Rotation; + position = hand.fingers[1].bones[0].NextJoint; + rotation = hand.fingers[1].bones[1].Rotation; break; case AttachmentPointFlags.IndexMiddleJoint: - position = hand.Fingers[1].bones[1].NextJoint; - rotation = hand.Fingers[1].bones[2].Rotation; + position = hand.fingers[1].bones[1].NextJoint; + rotation = hand.fingers[1].bones[2].Rotation; break; case AttachmentPointFlags.IndexDistalJoint: - position = hand.Fingers[1].bones[2].NextJoint; - rotation = hand.Fingers[1].bones[3].Rotation; + position = hand.fingers[1].bones[2].NextJoint; + rotation = hand.fingers[1].bones[3].Rotation; break; case AttachmentPointFlags.IndexTip: - position = hand.Fingers[1].bones[3].NextJoint; - rotation = hand.Fingers[1].bones[3].Rotation; + position = hand.fingers[1].bones[3].NextJoint; + rotation = hand.fingers[1].bones[3].Rotation; break; case AttachmentPointFlags.MiddleKnuckle: - position = hand.Fingers[2].bones[0].NextJoint; - rotation = hand.Fingers[2].bones[1].Rotation; + position = hand.fingers[2].bones[0].NextJoint; + rotation = hand.fingers[2].bones[1].Rotation; break; case AttachmentPointFlags.MiddleMiddleJoint: - position = hand.Fingers[2].bones[1].NextJoint; - rotation = hand.Fingers[2].bones[2].Rotation; + position = hand.fingers[2].bones[1].NextJoint; + rotation = hand.fingers[2].bones[2].Rotation; break; case AttachmentPointFlags.MiddleDistalJoint: - position = hand.Fingers[2].bones[2].NextJoint; - rotation = hand.Fingers[2].bones[3].Rotation; + position = hand.fingers[2].bones[2].NextJoint; + rotation = hand.fingers[2].bones[3].Rotation; break; case AttachmentPointFlags.MiddleTip: - position = hand.Fingers[2].bones[3].NextJoint; - rotation = hand.Fingers[2].bones[3].Rotation; + position = hand.fingers[2].bones[3].NextJoint; + rotation = hand.fingers[2].bones[3].Rotation; break; case AttachmentPointFlags.RingKnuckle: - position = hand.Fingers[3].bones[0].NextJoint; - rotation = hand.Fingers[3].bones[1].Rotation; + position = hand.fingers[3].bones[0].NextJoint; + rotation = hand.fingers[3].bones[1].Rotation; break; case AttachmentPointFlags.RingMiddleJoint: - position = hand.Fingers[3].bones[1].NextJoint; - rotation = hand.Fingers[3].bones[2].Rotation; + position = hand.fingers[3].bones[1].NextJoint; + rotation = hand.fingers[3].bones[2].Rotation; break; case AttachmentPointFlags.RingDistalJoint: - position = hand.Fingers[3].bones[2].NextJoint; - rotation = hand.Fingers[3].bones[3].Rotation; + position = hand.fingers[3].bones[2].NextJoint; + rotation = hand.fingers[3].bones[3].Rotation; break; case AttachmentPointFlags.RingTip: - position = hand.Fingers[3].bones[3].NextJoint; - rotation = hand.Fingers[3].bones[3].Rotation; + position = hand.fingers[3].bones[3].NextJoint; + rotation = hand.fingers[3].bones[3].Rotation; break; case AttachmentPointFlags.PinkyKnuckle: - position = hand.Fingers[4].bones[0].NextJoint; - rotation = hand.Fingers[4].bones[1].Rotation; + position = hand.fingers[4].bones[0].NextJoint; + rotation = hand.fingers[4].bones[1].Rotation; break; case AttachmentPointFlags.PinkyMiddleJoint: - position = hand.Fingers[4].bones[1].NextJoint; - rotation = hand.Fingers[4].bones[2].Rotation; + position = hand.fingers[4].bones[1].NextJoint; + rotation = hand.fingers[4].bones[2].Rotation; break; case AttachmentPointFlags.PinkyDistalJoint: - position = hand.Fingers[4].bones[2].NextJoint; - rotation = hand.Fingers[4].bones[3].Rotation; + position = hand.fingers[4].bones[2].NextJoint; + rotation = hand.fingers[4].bones[3].Rotation; break; case AttachmentPointFlags.PinkyTip: - position = hand.Fingers[4].bones[3].NextJoint; - rotation = hand.Fingers[4].bones[3].Rotation; + position = hand.fingers[4].bones[3].NextJoint; + rotation = hand.fingers[4].bones[3].Rotation; break; case AttachmentPointFlags.PinchPoint: position = hand.GetPredictedPinchPosition(); - rotation = Quaternion.LookRotation(position - hand.Fingers[1].Bone(Bone.BoneType.TYPE_PROXIMAL).PrevJoint); + rotation = Quaternion.LookRotation(position - hand.fingers[1].GetBone(Bone.BoneType.PROXIMAL).PrevJoint); break; } } diff --git a/Packages/Tracking/Core/Runtime/Scripts/Encoding/VectorHand.cs b/Packages/Tracking/Core/Runtime/Scripts/Encoding/VectorHand.cs index f0d67ce61e..df23927555 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Encoding/VectorHand.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Encoding/VectorHand.cs @@ -135,12 +135,12 @@ public void Encode(Hand fromHand) for (int i = 0; i < 5; i++) { Vector3 baseMetacarpal = ToLocal( - fromHand.Fingers[i].bones[0].PrevJoint, palmPos, palmRot); + fromHand.fingers[i].bones[0].PrevJoint, palmPos, palmRot); jointPositions[boneIdx++] = baseMetacarpal; for (int j = 0; j < 4; j++) { Vector3 joint = ToLocal( - fromHand.Fingers[i].bones[j].NextJoint, palmPos, palmRot); + fromHand.fingers[i].bones[j].NextJoint, palmPos, palmRot); jointPositions[boneIdx++] = joint; } } @@ -206,7 +206,7 @@ public void Decode(Hand intoHand) type: (Bone.BoneType)jointIdx, rotation: boneRot); } - intoHand.Fingers[fingerIdx].Fill( + intoHand.fingers[fingerIdx].Fill( frameId: -1, handId: (isLeft ? 0 : 1), fingerId: fingerIdx, @@ -545,7 +545,7 @@ public static class VectorHandExtensions /// public static Bone GetBone(this Hand hand, int boneIdx) { - return hand.Fingers[boneIdx / 4].bones[boneIdx % 4]; + return hand.fingers[boneIdx / 4].bones[boneIdx % 4]; } /// diff --git a/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseDetector.cs b/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseDetector.cs index 863e6fb661..96485ebb6b 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseDetector.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseDetector.cs @@ -174,8 +174,8 @@ public void CreatePoseRule() { PoseRule poseRule = new PoseRule(); poseRule.enabled = true; - poseRule.finger = (int)Finger.FingerType.TYPE_INDEX; - poseRule.bone = (int)Bone.BoneType.TYPE_INTERMEDIATE; + poseRule.finger = (int)Finger.FingerType.INDEX; + poseRule.bone = (int)Bone.BoneType.INTERMEDIATE; poseRule.directions = new List(); poseRules.Add(poseRule); @@ -327,14 +327,14 @@ private bool ComparePoseToHand(HandPoseScriptableObject pose, Hand playerHand) Quaternion lastSerializedBoneRotation = serializedHand.Rotation; // Each bone in the finger - for (int boneNum = 0; boneNum < serializedHand.Fingers[fingerNum].bones.Length; boneNum++) + for (int boneNum = 0; boneNum < serializedHand.fingers[fingerNum].bones.Length; boneNum++) { // Get the same bone for both comparison hand and player hand - Bone activeHandBone = playerHand.Fingers[fingerNum].bones[boneNum]; - Bone serializedHandBone = serializedHand.Fingers[fingerNum].bones[boneNum]; + Bone activeHandBone = playerHand.fingers[fingerNum].bones[boneNum]; + Bone serializedHandBone = serializedHand.fingers[fingerNum].bones[boneNum]; //Ignore the metacarpal as it will never really change. - if (serializedHandBone.Type == Bone.BoneType.TYPE_METACARPAL) + if (serializedHandBone.Type == Bone.BoneType.METACARPAL) { lastBoneRotation = activeHandBone.Rotation; lastSerializedBoneRotation = serializedHandBone.Rotation; @@ -343,7 +343,7 @@ private bool ComparePoseToHand(HandPoseScriptableObject pose, Hand playerHand) // Do not check distal for fingers, only for thumb if (fingerNum != 0 && - serializedHandBone.Type == Bone.BoneType.TYPE_DISTAL) + serializedHandBone.Type == Bone.BoneType.DISTAL) { continue; } @@ -372,7 +372,7 @@ private bool ComparePoseToHand(HandPoseScriptableObject pose, Hand playerHand) { if (boneDifference.x <= (jointRotationThresholds.x + pose.GetHysteresisThreshold()) && boneDifference.x >= (-jointRotationThresholds.x - pose.GetHysteresisThreshold())) { - if (serializedHandBone.Type == Bone.BoneType.TYPE_PROXIMAL) // Proximal also uses Y rotation for Abduction/Splay + if (serializedHandBone.Type == Bone.BoneType.PROXIMAL) // Proximal also uses Y rotation for Abduction/Splay { if (boneDifference.y <= (jointRotationThresholds.y + pose.GetHysteresisThreshold()) && boneDifference.y >= (-jointRotationThresholds.y - pose.GetHysteresisThreshold())) { @@ -390,7 +390,7 @@ private bool ComparePoseToHand(HandPoseScriptableObject pose, Hand playerHand) { if (boneDifference.x <= jointRotationThresholds.x && boneDifference.x >= -jointRotationThresholds.x) { - if (serializedHandBone.Type == Bone.BoneType.TYPE_PROXIMAL) // Proximal also uses Y rotation for Abduction/Splay + if (serializedHandBone.Type == Bone.BoneType.PROXIMAL) // Proximal also uses Y rotation for Abduction/Splay { if (boneDifference.y <= jointRotationThresholds.y && boneDifference.y >= -jointRotationThresholds.y) { @@ -454,8 +454,8 @@ private bool CheckPoseDirection(Hand playerHand) } else { - pointDirection = playerHand.Fingers[(int)rule.finger].bones[rule.bone].Direction.normalized; - pointPosition = playerHand.Fingers[(int)rule.finger].bones[rule.bone].NextJoint; + pointDirection = playerHand.fingers[(int)rule.finger].bones[rule.bone].Direction.normalized; + pointPosition = playerHand.fingers[(int)rule.finger].bones[rule.bone].NextJoint; } float hysteresisToAdd = 0; @@ -505,7 +505,7 @@ private bool CheckPoseDirection(Hand playerHand) } else { - jointRotation = playerHand.Fingers[(int)rule.finger].bones[rule.bone].Rotation; + jointRotation = playerHand.fingers[(int)rule.finger].bones[rule.bone].Rotation; } if (Quaternion.Angle(jointRotation, direction.poseTarget.rotation) < direction.rotationThreshold) diff --git a/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseEditor.cs b/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseEditor.cs index ccc5df01b1..cae8348dda 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseEditor.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseEditor.cs @@ -107,11 +107,11 @@ private void ShowEditorGizmos(Hand hand, HandPoseScriptableObject handPoseScript return; } - for (int j = 0; j < hand.Fingers.Count; j++) + for (int j = 0; j < hand.fingers.Length; j++) { - Finger finger = hand.Fingers[j]; - Bone proximal = finger.Bone(Bone.BoneType.TYPE_PROXIMAL); - Bone intermediate = finger.Bone(Bone.BoneType.TYPE_INTERMEDIATE); + Finger finger = hand.fingers[j]; + Bone proximal = finger.GetBone(Bone.BoneType.PROXIMAL); + Bone intermediate = finger.GetBone(Bone.BoneType.INTERMEDIATE); Plane fingerNormalPlane = new Plane(proximal.PrevJoint, proximal.NextJoint, intermediate.NextJoint); Vector3 normal = fingerNormalPlane.normal; @@ -128,7 +128,7 @@ private void ShowEditorGizmos(Hand hand, HandPoseScriptableObject handPoseScript bone.Direction.normalized, bone.PrevJoint, normal, gizmoColors[0], bone.Length); - if (finger.bones[i].Type == Bone.BoneType.TYPE_PROXIMAL) + if (finger.bones[i].Type == Bone.BoneType.PROXIMAL) { Vector3 proximalNormal = Quaternion.AngleAxis(90, bone.Direction.normalized) * normal; DrawThresholdGizmo(handPoseScriptableObject.GetBoneRotationthreshold(j, i - 1).y, // i-1 to ignore metacarpal diff --git a/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseValidator.cs b/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseValidator.cs index 6ba83cca6a..c0654b8b9c 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseValidator.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/HandPoses/HandPoseValidator.cs @@ -215,15 +215,15 @@ private void RenderDirectionRays() if (capsuleHand != null && capsuleHand.enabled) { if ((int)boneDirectionTarget.finger != 5 && - boneDirectionTarget.finger != (int)Leap.Finger.FingerType.TYPE_UNKNOWN && - boneDirectionTarget.bone != (int)Leap.Bone.BoneType.TYPE_INVALID) + boneDirectionTarget.finger != (int)Leap.Finger.FingerType.UNKNOWN && + boneDirectionTarget.bone != (int)Leap.Bone.BoneType.UNKNOWN) { int fingNum = (int)boneDirectionTarget.finger; int boneNum = (int)boneDirectionTarget.bone; if (capsuleHand.GetLeapHand() != null) { - var directionBone = capsuleHand.GetLeapHand().Fingers[fingNum].bones[boneNum]; + var directionBone = capsuleHand.GetLeapHand().fingers[fingNum].bones[boneNum]; if (directionBone.PrevJoint != null) { diff --git a/Packages/Tracking/Core/Runtime/Scripts/Hands/CapsuleHand.cs b/Packages/Tracking/Core/Runtime/Scripts/Hands/CapsuleHand.cs index 6f4f4bee7f..85915ed4ff 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Hands/CapsuleHand.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Hands/CapsuleHand.cs @@ -45,7 +45,7 @@ public CapsuleHandPreset Preset private const int TOTAL_JOINT_COUNT = 4 * 5; private const float CYLINDER_MESH_RESOLUTION = 0.1f; //in centimeters, meshes within this resolution will be re-used - private const int PINKY_BASE_INDEX = (int)Finger.FingerType.TYPE_PINKY * 4; + private const int PINKY_BASE_INDEX = (int)Finger.FingerType.PINKY * 4; private static int _leftColorIndex = 0; private static int _rightColorIndex = 0; @@ -361,7 +361,7 @@ public override void UpdateHand() } //Update all joint spheres in the fingers - foreach (var finger in _hand.Fingers) + foreach (var finger in _hand.fingers) { for (int j = 0; j < 4; j++) { @@ -369,14 +369,14 @@ public override void UpdateHand() Vector3 position; - if (finger.Type == Finger.FingerType.TYPE_THUMB && j == 0) + if (finger.Type == Finger.FingerType.THUMB && j == 0) { // Hand the base of the thumb differently, and move it to the base of the index metacarpal. - position = _hand.GetIndex().Bone((Bone.BoneType)j).PrevJoint; + position = _hand.Index.GetBone((Bone.BoneType)j).PrevJoint; } else { - position = finger.Bone((Bone.BoneType)j).NextJoint; + position = finger.GetBone((Bone.BoneType)j).NextJoint; } _spherePositions[key] = position; @@ -438,8 +438,8 @@ public override void UpdateHand() if (_showPinkyMetacarpal) { - Vector3 pinkyMetacarpal = _hand.GetPinky().Bone(Bone.BoneType.TYPE_METACARPAL).PrevJoint; - Vector3 indexMetacarpal = _hand.GetIndex().Bone(Bone.BoneType.TYPE_METACARPAL).PrevJoint; + Vector3 pinkyMetacarpal = _hand.Pinky.GetBone(Bone.BoneType.METACARPAL).PrevJoint; + Vector3 indexMetacarpal = _hand.Index.GetBone(Bone.BoneType.METACARPAL).PrevJoint; drawSphere(pinkyMetacarpal); drawCylinder(pinkyMetacarpal, indexMetacarpal); diff --git a/Packages/Tracking/Core/Runtime/Scripts/Hands/DebugHand.cs b/Packages/Tracking/Core/Runtime/Scripts/Hands/DebugHand.cs index 5a3ad75020..d7084b79ef 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Hands/DebugHand.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Hands/DebugHand.cs @@ -96,10 +96,10 @@ protected void DrawDebugLines() for (int f = 0; f < 5; f++) { //Fingers - Finger finger = hand.Fingers[f]; + Finger finger = hand.fingers[f]; for (int i = 0; i < 4; ++i) { - Bone bone = finger.Bone((Bone.BoneType)i); + Bone bone = finger.GetBone((Bone.BoneType)i); Debug.DrawLine(bone.PrevJoint, bone.PrevJoint + bone.Direction * bone.Length, colors[i]); if (VisualizeBasis) DrawBasis(bone.PrevJoint, bone.Basis, .01f); diff --git a/Packages/Tracking/Core/Runtime/Scripts/Hands/FingerModel.cs b/Packages/Tracking/Core/Runtime/Scripts/Hands/FingerModel.cs index bb4fd1a0ac..b99ad363e4 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Hands/FingerModel.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Hands/FingerModel.cs @@ -30,7 +30,7 @@ public abstract class FingerModel : MonoBehaviour /** The number of joints in a finger. */ public const int NUM_JOINTS = 3; - public Finger.FingerType fingerType = Finger.FingerType.TYPE_INDEX; + public Finger.FingerType fingerType = Finger.FingerType.INDEX; // Unity references /** Bones positioned and rotated by FingerModel. */ @@ -54,7 +54,7 @@ public void SetLeapHand(Hand hand) hand_ = hand; if (hand_ != null) { - finger_ = hand.Fingers[(int)fingerType]; + finger_ = hand.fingers[(int)fingerType]; } } @@ -86,7 +86,7 @@ public Vector3 GetTipPosition() { if (finger_ != null) { - Vector3 local_tip = finger_.Bone(Bone.BoneType.TYPE_DISTAL).NextJoint; + Vector3 local_tip = finger_.GetBone(Bone.BoneType.DISTAL).NextJoint; return local_tip; } if (bones[NUM_BONES - 1] && joints[NUM_JOINTS - 2]) @@ -105,7 +105,7 @@ public Vector3 GetJointPosition(int joint) } if (finger_ != null) { - Vector3 local_position = finger_.Bone((Bone.BoneType)joint).PrevJoint; + Vector3 local_position = finger_.GetBone((Bone.BoneType)joint).PrevJoint; return local_position; } if (joints[joint]) @@ -127,7 +127,7 @@ public Vector3 GetBoneCenter(int bone_type) { if (finger_ != null) { - Bone bone = finger_.Bone((Bone.BoneType)(bone_type)); + Bone bone = finger_.GetBone((Bone.BoneType)(bone_type)); return bone.Center; } if (bones[bone_type]) @@ -157,7 +157,7 @@ public Quaternion GetBoneRotation(int bone_type) { if (finger_ != null) { - Quaternion local_rotation = finger_.Bone((Bone.BoneType)bone_type).Rotation; + Quaternion local_rotation = finger_.GetBone((Bone.BoneType)bone_type).Rotation; return local_rotation; } if (bones[bone_type]) @@ -170,13 +170,13 @@ public Quaternion GetBoneRotation(int bone_type) /** Returns the length of the finger bone.*/ public float GetBoneLength(int bone_type) { - return finger_.Bone((Bone.BoneType)(bone_type)).Length; + return finger_.GetBone((Bone.BoneType)(bone_type)).Length; } /** Returns the width of the finger bone.*/ public float GetBoneWidth(int bone_type) { - return finger_.Bone((Bone.BoneType)(bone_type)).Width; + return finger_.GetBone((Bone.BoneType)(bone_type)).Width; } /** @@ -191,8 +191,8 @@ public float GetFingerJointStretchMecanim(int joint_type) Quaternion jointRotation = Quaternion.identity; if (finger_ != null) { - jointRotation = Quaternion.Inverse(finger_.Bone((Bone.BoneType)joint_type).Rotation) - * finger_.Bone((Bone.BoneType)(joint_type + 1)).Rotation; + jointRotation = Quaternion.Inverse(finger_.GetBone((Bone.BoneType)joint_type).Rotation) + * finger_.GetBone((Bone.BoneType)(joint_type + 1)).Rotation; } else if (bones[joint_type] && bones[joint_type + 1]) { @@ -222,8 +222,8 @@ public float GetFingerJointSpreadMecanim() Quaternion jointRotation = Quaternion.identity; if (finger_ != null) { - jointRotation = Quaternion.Inverse(finger_.Bone((Bone.BoneType)0).Rotation) - * finger_.Bone((Bone.BoneType)1).Rotation; + jointRotation = Quaternion.Inverse(finger_.GetBone((Bone.BoneType)0).Rotation) + * finger_.GetBone((Bone.BoneType)1).Rotation; } else if (bones[0] && bones[1]) { @@ -237,8 +237,8 @@ public float GetFingerJointSpreadMecanim() fingerType = finger_.Type; } - if (fType == Finger.FingerType.TYPE_INDEX || - fType == Finger.FingerType.TYPE_MIDDLE) + if (fType == Finger.FingerType.INDEX || + fType == Finger.FingerType.MIDDLE) { spreadAngle = jointRotation.eulerAngles.y; if (spreadAngle > 180f) @@ -247,9 +247,9 @@ public float GetFingerJointSpreadMecanim() } // NOTE: eulerAngles range is [0, 360) so spreadAngle <= -180f will not occur. } - if (fType == Finger.FingerType.TYPE_THUMB || - fType == Finger.FingerType.TYPE_RING || - fType == Finger.FingerType.TYPE_PINKY) + if (fType == Finger.FingerType.THUMB || + fType == Finger.FingerType.RING || + fType == Finger.FingerType.PINKY) { spreadAngle = -jointRotation.eulerAngles.y; if (spreadAngle <= -180f) diff --git a/Packages/Tracking/Core/Runtime/Scripts/Hands/TestHandFactory.cs b/Packages/Tracking/Core/Runtime/Scripts/Hands/TestHandFactory.cs index 857f5ed082..42a1dc431d 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Hands/TestHandFactory.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Hands/TestHandFactory.cs @@ -149,12 +149,12 @@ public static LeapTransform GetTestPoseLeftHandTransform(TestHandPose pose) private static Hand makeLeapSpaceTestHand(int frameId, int handId, bool isLeft) { - List fingers = new List(5); - fingers.Add(makeThumb(frameId, handId, isLeft)); - fingers.Add(makeIndexFinger(frameId, handId, isLeft)); - fingers.Add(makeMiddleFinger(frameId, handId, isLeft)); - fingers.Add(makeRingFinger(frameId, handId, isLeft)); - fingers.Add(makePinky(frameId, handId, isLeft)); + Finger[] fingers = new Finger[5]; + fingers[0] = makeThumb(frameId, handId, isLeft); + fingers[1] = makeIndexFinger(frameId, handId, isLeft); + fingers[2] = makeMiddleFinger(frameId, handId, isLeft); + fingers[3] = makeRingFinger(frameId, handId, isLeft); + fingers[4] = makePinky(frameId, handId, isLeft); Vector3 armWrist = new Vector3(-7.05809944059f, 4.0f, 50.0f); Vector3 elbow = armWrist + 250f * Vector3.forward; @@ -212,7 +212,7 @@ private static Finger makeThumb(int frameId, int handId, bool isLeft) Vector3 forward = new Vector3(0.636329113772f, -0.5f, -0.899787143982f); Vector3 up = new Vector3(0.804793943718f, 0.447213915513f, 0.390264553767f); float[] jointLengths = { 0.0f, 46.22f, 31.57f, 21.67f }; - return makeFinger(Finger.FingerType.TYPE_THUMB, position, forward, up, jointLengths, frameId, handId, handId + 0, isLeft); + return makeFinger(Finger.FingerType.THUMB, position, forward, up, jointLengths, frameId, handId, handId + 0, isLeft); } private static Finger makeIndexFinger(int frameId, int handId, bool isLeft) @@ -221,7 +221,7 @@ private static Finger makeIndexFinger(int frameId, int handId, bool isLeft) Vector3 forward = new Vector3(0.166044313785f, -0.14834045293f, -0.974897120667f); Vector3 up = new Vector3(0.0249066470677f, 0.988936352868f, -0.1462345681f); float[] jointLengths = { 68.12f, 39.78f, 22.38f, 15.82f }; - return makeFinger(Finger.FingerType.TYPE_INDEX, position, forward, up, jointLengths, frameId, handId, handId + 1, isLeft); + return makeFinger(Finger.FingerType.INDEX, position, forward, up, jointLengths, frameId, handId, handId + 1, isLeft); } private static Finger makeMiddleFinger(int frameId, int handId, bool isLeft) @@ -230,7 +230,7 @@ private static Finger makeMiddleFinger(int frameId, int handId, bool isLeft) Vector3 forward = new Vector3(0.0295207858556f, -0.148340452932f, -0.988495641481f); Vector3 up = new Vector3(-0.145765270107f, 0.977715980076f, -0.151075968756f); float[] jointLengths = { 64.60f, 44.63f, 26.33f, 17.40f }; - return makeFinger(Finger.FingerType.TYPE_MIDDLE, position, forward, up, jointLengths, frameId, handId, handId + 2, isLeft); + return makeFinger(Finger.FingerType.MIDDLE, position, forward, up, jointLengths, frameId, handId, handId + 2, isLeft); } private static Finger makeRingFinger(int frameId, int handId, bool isLeft) @@ -239,7 +239,7 @@ private static Finger makeRingFinger(int frameId, int handId, bool isLeft) Vector3 forward = new Vector3(-0.121317937368f, -0.148340347175f, -0.981466810174f); Vector3 up = new Vector3(-0.216910468316f, 0.968834928679f, -0.119619102602f); float[] jointLengths = { 58.00f, 41.37f, 25.65f, 17.30f }; - return makeFinger(Finger.FingerType.TYPE_RING, position, forward, up, jointLengths, frameId, handId, handId + 3, isLeft); + return makeFinger(Finger.FingerType.RING, position, forward, up, jointLengths, frameId, handId, handId + 3, isLeft); } private static Finger makePinky(int frameId, int handId, bool isLeft) @@ -248,7 +248,7 @@ private static Finger makePinky(int frameId, int handId, bool isLeft) Vector3 forward = new Vector3(-0.259328923438f, -0.105851224797f, -0.959970847306f); Vector3 up = new Vector3(-0.353350220937f, 0.935459475557f, -0.00769356576168f); float[] jointLengths = { 53.69f, 32.74f, 18.11f, 15.96f }; - return makeFinger(Finger.FingerType.TYPE_PINKY, position, forward, up, jointLengths, frameId, handId, handId + 4, isLeft); + return makeFinger(Finger.FingerType.PINKY, position, forward, up, jointLengths, frameId, handId, handId + 4, isLeft); } @@ -261,19 +261,19 @@ private static Finger makePinky(int frameId, int handId, bool isLeft) Bone[] bones = new Bone[5]; float proximalDistance = -jointLengths[0]; - Bone metacarpal = makeBone(Bone.BoneType.TYPE_METACARPAL, position + forward * proximalDistance, jointLengths[0], 8f, forward, up, isLeft); + Bone metacarpal = makeBone(Bone.BoneType.METACARPAL, position + forward * proximalDistance, jointLengths[0], 8f, forward, up, isLeft); proximalDistance += jointLengths[0]; bones[0] = metacarpal; - Bone proximal = makeBone(Bone.BoneType.TYPE_PROXIMAL, position + forward * proximalDistance, jointLengths[1], 8f, forward, up, isLeft); + Bone proximal = makeBone(Bone.BoneType.PROXIMAL, position + forward * proximalDistance, jointLengths[1], 8f, forward, up, isLeft); proximalDistance += jointLengths[1]; bones[1] = proximal; - Bone intermediate = makeBone(Bone.BoneType.TYPE_INTERMEDIATE, position + forward * proximalDistance, jointLengths[2], 8f, forward, up, isLeft); + Bone intermediate = makeBone(Bone.BoneType.INTERMEDIATE, position + forward * proximalDistance, jointLengths[2], 8f, forward, up, isLeft); proximalDistance += jointLengths[2]; bones[2] = intermediate; - Bone distal = makeBone(Bone.BoneType.TYPE_DISTAL, position + forward * proximalDistance, jointLengths[3], 8f, forward, up, isLeft); + Bone distal = makeBone(Bone.BoneType.DISTAL, position + forward * proximalDistance, jointLengths[3], 8f, forward, up, isLeft); bones[3] = distal; return new Finger(frameId, diff --git a/Packages/Tracking/Core/Runtime/Scripts/Utils/HandUtils.cs b/Packages/Tracking/Core/Runtime/Scripts/Utils/HandUtils.cs index 8435899078..af6b6db076 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Utils/HandUtils.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Utils/HandUtils.cs @@ -94,39 +94,6 @@ public static LeapXRServiceProvider CreateXRLeapProviderManager() return leapXRServiceProvider; } - /// - /// Finds the Camera Rig; Assuming a Camera is a child of the Camera Rig and the static Provider is a child of the Camera. - /// - private static void AssignCameraRig() - { - Camera providerCamera = Provider?.GetComponentInParent(); - - if (providerCamera == null || providerCamera.transform.parent == null) - { - return; - } - - s_leapRig = providerCamera.transform.parent.gameObject; - } - - /// - /// Static convenience accessor for the Leap camera rig. This is the parent - /// of the Camera that contains a LeapProvider in one of its children, - /// or null if there is no such GameObject. - /// - public static GameObject CameraRig - { - get - { - if (s_leapRig == null) - { - AssignCameraRig(); - } - return s_leapRig; - } - set { s_leapRig = value; } - } - /// /// Static convenience accessor for a LeapProvider in the scene. Preference is given /// to a LeapServiceProvider if there is one. @@ -153,129 +120,33 @@ public static LeapProvider Provider } /// - /// Returns the first hand of the argument Chirality in the current frame, - /// otherwise returns null if no such hand is found. - /// - [Obsolete("Specifying Providers is highly recommended. Use LeapProvider.GetHand() instead")] - public static Hand Get(Chirality chirality) - { - if (chirality == Chirality.Left) return Left; - else return Right; - } - - /// - /// As Get, but returns the FixedUpdate (physics timestep) hand as opposed to the Update hand. - /// - [Obsolete("Specifying Providers is highly recommended. Use LeapProvider.GetHand() instead")] - public static Hand GetFixed(Chirality chirality) - { - if (chirality == Chirality.Left) return FixedLeft; - else return FixedRight; - } - - /// - /// Returns the first left hand found by Leap in the current frame, otherwise - /// returns null if no such hand is found. - /// - [Obsolete("Specifying Providers is highly recommended. Use LeapProvider.GetHand(Chirality.Left) instead")] - public static Hand Left - { - get - { - if (Provider == null) return null; - if (Provider.CurrentFrame == null) return null; - return Provider.CurrentFrame.GetHand(Chirality.Left); - } - } - - /// - /// Returns the first right hand found by Leap in the current frame, otherwise - /// returns null if no such hand is found. - /// - [Obsolete("Specifying Providers is highly recommended. Use LeapProvider.GetHand(Chirality.Right) instead")] - public static Hand Right - { - get - { - if (Provider == null) return null; - if (Provider.CurrentFrame == null) return null; - return Provider.CurrentFrame.GetHand(Chirality.Right); - } - } - - /// - /// Returns the first left hand found by Leap in the current fixed frame, otherwise - /// returns null if no such hand is found. The fixed frame is aligned with the physics timestep. - /// - [Obsolete("Specifying Providers is highly recommended. Use LeapProvider.GetHand(Chirality.Left) instead")] - public static Hand FixedLeft - { - get - { - if (Provider == null) return null; - if (Provider.CurrentFixedFrame == null) return null; - return Provider.CurrentFixedFrame.GetHand(Chirality.Left); - } - } - - /// - /// Returns the first right hand found by Leap in the current fixed frame, otherwise - /// returns null if no such hand is found. The fixed frame is aligned with the physics timestep. - /// - [Obsolete("Specifying Providers is highly recommended. Use LeapProvider.GetHand(Chirality.Right) instead")] - public static Hand FixedRight - { - get - { - if (Provider == null) return null; - if (Provider.CurrentFixedFrame == null) return null; - return Provider.CurrentFixedFrame.GetHand(Chirality.Right); - } - } - - /// - /// Shorthand for hand.Fingers[(int)Leap.Finger.FingerType.TYPE_THUMB], - /// or, alternatively, hand.Fingers[0]. - /// - public static Finger GetThumb(this Hand hand) - { - return hand.Fingers[(int)Leap.Finger.FingerType.TYPE_THUMB]; - } - - /// - /// Shorthand for hand.Fingers[(int)Leap.Finger.FingerType.TYPE_INDEX], - /// or, alternatively, hand.Fingers[1]. - /// - public static Finger GetIndex(this Hand hand) - { - return hand.Fingers[(int)Leap.Finger.FingerType.TYPE_INDEX]; - } - - /// - /// Shorthand for hand.Fingers[(int)Leap.Finger.FingerType.TYPE_MIDDLE], - /// or, alternatively, hand.Fingers[2]. + /// Return the specified bone of the specified finger + /// + /// Shorthand for finger.bones[(int)boneType], /// - public static Finger GetMiddle(this Hand hand) + public static Bone GetBone(this Finger finger, Bone.BoneType boneType) { - return hand.Fingers[(int)Leap.Finger.FingerType.TYPE_MIDDLE]; + return finger.bones[(int)boneType]; } /// - /// Shorthand for hand.Fingers[(int)Leap.Finger.FingerType.TYPE_RING], - /// or, alternatively, hand.Fingers[3]. + /// Return the specified bone of the specified finger of the specificed hand + /// + /// Shorthand for hand.Fingers[(int)fingerType].bones[(int)boneType], /// - public static Finger GetRing(this Hand hand) + public static Bone GetBone(this Hand hand, Finger.FingerType fingerType, Bone.BoneType boneType) { - return hand.Fingers[(int)Leap.Finger.FingerType.TYPE_RING]; + return hand.fingers[(int)fingerType].bones[(int)boneType]; } /// - /// Shorthand for hand.Fingers[(int)Leap.Finger.FingerType.TYPE_PINKY], - /// or, alternatively, hand.Fingers[4]. + /// Return the specified finger of the specificed hand + /// + /// Shorthand for hand.Fingers[(int)fingerType].Bones[], /// - public static Finger GetPinky(this Hand hand) + public static Finger GetFinger(this Hand hand, Finger.FingerType fingerType) { - return hand.Fingers[(int)Leap.Finger.FingerType.TYPE_PINKY]; + return hand.fingers[(int)fingerType]; } /// @@ -348,8 +219,8 @@ public static bool IsPinching(this Hand hand) /// public static Vector3 GetPinchPosition(this Hand hand) { - Vector3 indexPosition = hand.Fingers[(int)Finger.FingerType.TYPE_INDEX].TipPosition; - Vector3 thumbPosition = hand.Fingers[(int)Finger.FingerType.TYPE_THUMB].TipPosition; + Vector3 indexPosition = hand.fingers[(int)Finger.FingerType.INDEX].TipPosition; + Vector3 thumbPosition = hand.fingers[(int)Finger.FingerType.THUMB].TipPosition; return (2 * thumbPosition + indexPosition) * 0.333333F; } @@ -361,14 +232,14 @@ public static Vector3 GetPinchPosition(this Hand hand) /// public static Vector3 GetPredictedPinchPosition(this Hand hand) { - Vector3 indexTip = hand.GetIndex().TipPosition; - Vector3 thumbTip = hand.GetThumb().TipPosition; + Vector3 indexTip = hand.Index.TipPosition; + Vector3 thumbTip = hand.Thumb.TipPosition; // The predicted pinch point is a rigid point in hand-space linearly offset by the // index finger knuckle position, scaled by the index finger's length, and lightly // influenced by the actual thumb and index tip positions. - Vector3 indexKnuckle = hand.Fingers[1].bones[1].PrevJoint; - float indexLength = hand.Fingers[1].Length; + Vector3 indexKnuckle = hand.fingers[1].bones[1].PrevJoint; + float indexLength = hand.fingers[1].Length; Vector3 radialAxis = hand.RadialAxis(); float thumbInfluence = Vector3.Dot((thumbTip - indexKnuckle).normalized, radialAxis).Map(0F, 1F, 0.5F, 0F); Vector3 predictedPinchPoint = indexKnuckle + hand.PalmarAxis() * indexLength * 0.85F @@ -390,8 +261,8 @@ public static Vector3 GetStablePinchPosition(this Hand hand) // The stable pinch point is a rigid point in hand-space linearly offset by the // index finger knuckle position and scaled by the index finger's length - Vector3 indexKnuckle = hand.Fingers[1].bones[1].PrevJoint; - float indexLength = hand.Fingers[1].Length; + Vector3 indexKnuckle = hand.fingers[1].bones[1].PrevJoint; + float indexLength = hand.fingers[1].Length; Vector3 radialAxis = hand.RadialAxis(); Vector3 stablePinchPoint = indexKnuckle + hand.PalmarAxis() * indexLength * 0.85F + hand.DistalAxis() * indexLength * 0.20F @@ -418,11 +289,11 @@ public static float GetFistStrength(this Hand hand) return 0; } - return (Vector3.Dot(hand.Fingers[1].Direction, -hand.DistalAxis()) - + Vector3.Dot(hand.Fingers[2].Direction, -hand.DistalAxis()) - + Vector3.Dot(hand.Fingers[3].Direction, -hand.DistalAxis()) - + Vector3.Dot(hand.Fingers[4].Direction, -hand.DistalAxis()) - + Vector3.Dot(hand.Fingers[0].Direction, -hand.RadialAxis()) + return (Vector3.Dot(hand.fingers[1].Direction, -hand.DistalAxis()) + + Vector3.Dot(hand.fingers[2].Direction, -hand.DistalAxis()) + + Vector3.Dot(hand.fingers[3].Direction, -hand.DistalAxis()) + + Vector3.Dot(hand.fingers[4].Direction, -hand.DistalAxis()) + + Vector3.Dot(hand.fingers[0].Direction, -hand.RadialAxis()) ).Map(-5, 5, 0, 1); } @@ -438,10 +309,10 @@ public static float GetFingerStrength(this Hand hand, int finger) if (finger == 0) { - return Vector3.Dot(hand.Fingers[finger].Direction, -hand.RadialAxis()).Map(-1, 1, 0, 1); + return Vector3.Dot(hand.fingers[finger].Direction, -hand.RadialAxis()).Map(-1, 1, 0, 1); } - return Vector3.Dot(hand.Fingers[finger].Direction, -hand.DistalAxis()).Map(-1, 1, 0, 1); + return Vector3.Dot(hand.fingers[finger].Direction, -hand.DistalAxis()).Map(-1, 1, 0, 1); } /// @@ -455,7 +326,7 @@ public static float GetFingerPinchDistance(this Hand hand, int finger) return float.MaxValue; } - return Vector3.Distance(hand.Fingers[0].TipPosition, hand.Fingers[finger].TipPosition); + return Vector3.Distance(hand.fingers[0].TipPosition, hand.fingers[finger].TipPosition); } /// @@ -476,9 +347,9 @@ public static float CalculateHandScale(ref Hand hand) { // Iterate through the fingers, skipping the thumb and accumulate the scale. float scale = 0.0f; - for (var i = 1; i < hand.Fingers.Count; ++i) + for (var i = 1; i < hand.fingers.Length; ++i) { - scale += (hand.Fingers[i].Bone(Bone.BoneType.TYPE_METACARPAL).Length / DefaultMetacarpalLengths[i]) / 4.0f; + scale += (hand.fingers[i].GetBone(Bone.BoneType.METACARPAL).Length / DefaultMetacarpalLengths[i]) / 4.0f; } return scale; @@ -492,15 +363,15 @@ public static float CalculateHandScale(ref Hand hand) public static float CalculatePinchStrength(ref Hand hand) { // Get the thumb position. - Vector3 thumbTipPosition = hand.GetThumb().TipPosition; + Vector3 thumbTipPosition = hand.Thumb.TipPosition; // Compute the distance midpoints between the thumb and the each finger and find the smallest. float minDistanceSquared = float.MaxValue; // Iterate through the fingers, skipping the thumb. - for (var i = 1; i < hand.Fingers.Count; ++i) + for (var i = 1; i < hand.fingers.Length; ++i) { - float distanceSquared = (hand.Fingers[i].TipPosition - thumbTipPosition).sqrMagnitude; + float distanceSquared = (hand.fingers[i].TipPosition - thumbTipPosition).sqrMagnitude; minDistanceSquared = Mathf.Min(distanceSquared, minDistanceSquared); } @@ -521,13 +392,13 @@ public static float CalculatePinchDistance(ref Hand hand) { // Get the farthest 2 segments of thumb and index finger, respectively, and compute distances. float minDistanceSquared = float.MaxValue; - for (var thumbBoneIndex = 2; thumbBoneIndex < hand.GetThumb().bones.Length; ++thumbBoneIndex) + for (var thumbBoneIndex = 2; thumbBoneIndex < hand.Thumb.bones.Length; ++thumbBoneIndex) { - for (var indexBoneIndex = 2; indexBoneIndex < hand.GetIndex().bones.Length; ++indexBoneIndex) + for (var indexBoneIndex = 2; indexBoneIndex < hand.Index.bones.Length; ++indexBoneIndex) { var distanceSquared = CalculateBoneDistanceSquared( - hand.GetThumb().bones[thumbBoneIndex], - hand.GetIndex().bones[indexBoneIndex]); + hand.Thumb.bones[thumbBoneIndex], + hand.Index.bones[indexBoneIndex]); minDistanceSquared = Mathf.Min(distanceSquared, minDistanceSquared); } } @@ -594,7 +465,7 @@ public static Ray HandRay(this Hand hand, Transform headTransform) // Compare against this //Vector3 ProjectionOrigin = headTransform.position + shoulderYaw * // new Vector3(0.15f * (hand.IsLeft ? -1f : 1f), -0.13f, 0.05f); - Vector3 ProjectionDirection = hand.Fingers[1].bones[0].NextJoint - ProjectionOrigin; + Vector3 ProjectionDirection = hand.fingers[1].bones[0].NextJoint - ProjectionOrigin; return new Ray(ProjectionOrigin, ProjectionDirection); } @@ -679,7 +550,7 @@ public static class HandUtils bool isLeft, float timeVisible, /* Arm arm,*/ - List fingers, + Finger[] fingers, Vector3 palmPosition, Vector3 stabilizedPalmPosition, Vector3 palmVelocity, @@ -697,7 +568,7 @@ public static class HandUtils toFill.PalmWidth = palmWidth; toFill.IsLeft = isLeft; toFill.TimeVisible = timeVisible; - if (fingers != null) toFill.Fingers = fingers; + if (fingers != null) toFill.fingers = fingers; toFill.PalmPosition = palmPosition; toFill.StabilizedPalmPosition = stabilizedPalmPosition; toFill.PalmVelocity = palmVelocity; diff --git a/Packages/Tracking/Core/Runtime/Scripts/Utils/PinchDetector.cs b/Packages/Tracking/Core/Runtime/Scripts/Utils/PinchDetector.cs index 31a8725830..afef3ae778 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/Utils/PinchDetector.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/Utils/PinchDetector.cs @@ -19,10 +19,10 @@ public class PinchDetector : MonoBehaviour { public enum PinchableFingerType { - INDEX = Finger.FingerType.TYPE_INDEX, - MIDDLE = Finger.FingerType.TYPE_MIDDLE, - RING = Finger.FingerType.TYPE_RING, - PINKY = Finger.FingerType.TYPE_PINKY, + INDEX = Finger.FingerType.INDEX, + MIDDLE = Finger.FingerType.MIDDLE, + RING = Finger.FingerType.RING, + PINKY = Finger.FingerType.PINKY, } public LeapProvider leapProvider; diff --git a/Packages/Tracking/Core/Runtime/Scripts/XRHandsSubsystem/LeapHandsSubsystem.cs b/Packages/Tracking/Core/Runtime/Scripts/XRHandsSubsystem/LeapHandsSubsystem.cs index 8a5875aac7..6b0bdd0ab6 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/XRHandsSubsystem/LeapHandsSubsystem.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/XRHandsSubsystem/LeapHandsSubsystem.cs @@ -173,9 +173,9 @@ bool PopulateXRHandFromLeap(Hand leapHand, ref Pose rootPose, ref NativeArray _pinchDeactivateDistance || distanceToRestingPos > _stretchThreshold)) { diff --git a/Packages/Tracking/Examples~/XR Examples/Example Assets Old/Scripts/Turntable/Turntable.cs b/Packages/Tracking/Examples~/XR Examples/Example Assets Old/Scripts/Turntable/Turntable.cs index a263637b5f..3ac6cb239d 100644 --- a/Packages/Tracking/Examples~/XR Examples/Example Assets Old/Scripts/Turntable/Turntable.cs +++ b/Packages/Tracking/Examples~/XR Examples/Example Assets Old/Scripts/Turntable/Turntable.cs @@ -120,10 +120,10 @@ private void Update() foreach (var hand in _provider.CurrentFrame.Hands) { // use a fingerID that allows for unique IDs for each finger of each hand. 0-4 = left, 5-9 = right - int fingerID = hand.IsLeft ? 0 : hand.Fingers.Count; - foreach (var finger in hand.Fingers) + int fingerID = hand.IsLeft ? 0 : hand.fingers.Length; + foreach (var finger in hand.fingers) { - Vector3 worldTip = finger.Bone(Bone.BoneType.TYPE_DISTAL).NextJoint; + Vector3 worldTip = finger.GetBone(Bone.BoneType.DISTAL).NextJoint; Vector3 localTip = transform.InverseTransformPoint(worldTip); if (IsPointInsideTurntable(localTip)) diff --git a/Packages/Tracking/Examples~/XR Examples/Example Assets/Pinch to Paint/Scripts/PaintCursor.cs b/Packages/Tracking/Examples~/XR Examples/Example Assets/Pinch to Paint/Scripts/PaintCursor.cs index c18c99078e..3886205e97 100644 --- a/Packages/Tracking/Examples~/XR Examples/Example Assets/Pinch to Paint/Scripts/PaintCursor.cs +++ b/Packages/Tracking/Examples~/XR Examples/Example Assets/Pinch to Paint/Scripts/PaintCursor.cs @@ -56,7 +56,7 @@ public bool DidStartPinch protected virtual void OnEnable() { - _minRadius = pinchDetector.ActivateDistance / 2F; + _minRadius = pinchDetector.activateDistance / 2F; } protected virtual void Update() @@ -64,7 +64,7 @@ protected virtual void Update() Hand hand = null; pinchDetector.TryGetHand(out hand); - if (hand == null || hand.GetIndex() == null || hand.GetThumb() == null) + if (hand == null || hand.Index == null || hand.Thumb == null) { _rectToroidPinchTargetRenderer.enabled = false; _rectToroidPinchStateRenderer.enabled = false; @@ -74,8 +74,8 @@ protected virtual void Update() _rectToroidPinchTargetRenderer.enabled = true; _rectToroidPinchStateRenderer.enabled = true; - var indexPos = hand.GetIndex().TipPosition; - var thumbPos = hand.GetThumb().TipPosition; + var indexPos = hand.Index.TipPosition; + var thumbPos = hand.Thumb.TipPosition; var indexThumbDist = Vector3.Distance(indexPos, thumbPos); // Update the cursor position diff --git a/Packages/Tracking/Hands/Editor/HandBinderEditor.cs b/Packages/Tracking/Hands/Editor/HandBinderEditor.cs index 8e0f9f42bd..2df3615fe5 100644 --- a/Packages/Tracking/Hands/Editor/HandBinderEditor.cs +++ b/Packages/Tracking/Hands/Editor/HandBinderEditor.cs @@ -480,12 +480,12 @@ void DrawModelHandGizmos() { for (int i = 0; i < 5; i++) { - var indexCheck = (int)Bone.BoneType.TYPE_METACARPAL; + var indexCheck = (int)Bone.BoneType.METACARPAL; //The hand binder does not use the METACARPAL bone for the thumb so draw a line to the proximal instead - if ((Leap.Finger.FingerType)i == Finger.FingerType.TYPE_THUMB) + if ((Leap.Finger.FingerType)i == Finger.FingerType.THUMB) { - indexCheck = (int)Bone.BoneType.TYPE_PROXIMAL; + indexCheck = (int)Bone.BoneType.PROXIMAL; } var joint = myTarget.BoundHand.fingers[i]; @@ -513,7 +513,7 @@ void DrawLeapHandGizmos() if (debugLeapHand.boolValue) { Handles.color = leapHandDebugCol; - foreach (var finger in myTarget.LeapHand.Fingers) + foreach (var finger in myTarget.LeapHand.fingers) { var index = 0; @@ -533,11 +533,11 @@ void DrawLeapHandGizmos() } Handles.SphereHandleCap(-1, myTarget.LeapHand.WristPosition, Quaternion.identity, gizmoSize.floatValue, EventType.Repaint); - Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.Fingers[0].bones[0].PrevJoint); - Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.Fingers[1].bones[0].PrevJoint); - Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.Fingers[2].bones[0].PrevJoint); - Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.Fingers[3].bones[0].PrevJoint); - Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.Fingers[4].bones[0].PrevJoint); + Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.fingers[0].bones[0].PrevJoint); + Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.fingers[1].bones[0].PrevJoint); + Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.fingers[2].bones[0].PrevJoint); + Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.fingers[3].bones[0].PrevJoint); + Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.fingers[4].bones[0].PrevJoint); Handles.DrawAAPolyLine(myTarget.LeapHand.WristPosition, myTarget.LeapHand.Arm.PrevJoint); Handles.SphereHandleCap(-1, myTarget.LeapHand.Arm.PrevJoint, Quaternion.identity, gizmoSize.floatValue, EventType.Repaint); } @@ -550,7 +550,7 @@ void DrawLeapBasis() { if (DebugLeapRotationAxis.boolValue) { - foreach (var FINGER in myTarget.LeapHand.Fingers) + foreach (var FINGER in myTarget.LeapHand.fingers) { foreach (var BONE in FINGER.bones) { @@ -739,7 +739,7 @@ void DrawObjectFields() var objectFieldName = ""; for (int boneID = 0; boneID < handBinder.BoundHand.fingers[fingerID].boundBones.Length; boneID++) { - if ((Finger.FingerType)fingerID == Finger.FingerType.TYPE_THUMB && (Bone.BoneType)boneID == Bone.BoneType.TYPE_METACARPAL) + if ((Finger.FingerType)fingerID == Finger.FingerType.THUMB && (Bone.BoneType)boneID == Bone.BoneType.METACARPAL) { continue; } diff --git a/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinder.cs b/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinder.cs index 046905adef..a4780963ee 100644 --- a/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinder.cs +++ b/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinder.cs @@ -191,7 +191,7 @@ void SetHandScale() for (int i = 0; i < BoundHand.fingers.Length; i++) { var finger = BoundHand.fingers[i]; - var lastBone = finger.boundBones[(int)Bone.BoneType.TYPE_DISTAL]; + var lastBone = finger.boundBones[(int)Bone.BoneType.DISTAL]; if (lastBone.boundTransform == null || lastBone.startTransform.scale == Vector3.zero) continue; @@ -241,9 +241,9 @@ void ScaleFingertips() for (int i = 0; i < BoundHand.fingers.Length; i++) { BoundFinger finger = BoundHand.fingers[i]; - BoundBone distalBone = finger.boundBones[(int)Bone.BoneType.TYPE_DISTAL]; - BoundBone intermediateBone = finger.boundBones[(int)Bone.BoneType.TYPE_INTERMEDIATE]; - Finger leapFinger = LeapHand.Fingers[i]; + BoundBone distalBone = finger.boundBones[(int)Bone.BoneType.DISTAL]; + BoundBone intermediateBone = finger.boundBones[(int)Bone.BoneType.INTERMEDIATE]; + Finger leapFinger = LeapHand.fingers[i]; //Check we have the correct information to be able to scale if (intermediateBone.boundTransform == null || distalBone.boundTransform == null || leapFinger == null || finger.fingerTipBaseLength == 0) @@ -375,7 +375,7 @@ void TransformFingerBones() { var boundBone = finger.boundBones[boneIndex]; var startTransform = boundBone.startTransform; - var leapBone = LeapHand.Fingers[fingerIndex].bones[boneIndex]; + var leapBone = LeapHand.fingers[fingerIndex].bones[boneIndex]; var boneOffset = boundBone.offset; var boundTransform = boundBone.boundTransform; @@ -427,13 +427,13 @@ float CalculateLeapMiddleFingerLength(Hand hand) bool AddedWristToFirstBone = false; var length = 0f; - for (int i = 0; i < hand.Fingers[(int)Finger.FingerType.TYPE_MIDDLE].bones.Length; i++) + for (int i = 0; i < hand.fingers[(int)Finger.FingerType.MIDDLE].bones.Length; i++) { //If the bound hand does not contain a bone then don't count this in the calculation for leap length - var boundBone = BoundHand.fingers[(int)Finger.FingerType.TYPE_MIDDLE].boundBones[i]; + var boundBone = BoundHand.fingers[(int)Finger.FingerType.MIDDLE].boundBones[i]; if (boundBone.boundTransform != null) { - var bone = hand.Fingers[(int)Finger.FingerType.TYPE_MIDDLE].bones[i]; + var bone = hand.fingers[(int)Finger.FingerType.MIDDLE].bones[i]; if (!AddedWristToFirstBone) { diff --git a/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderAutoBinder.cs b/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderAutoBinder.cs index 06cc2a1068..9a6899fa7b 100644 --- a/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderAutoBinder.cs +++ b/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderAutoBinder.cs @@ -261,9 +261,9 @@ public static BoundBone AssignBoundBone(Transform transform) public static void EstimateWristRotationOffset(HandBinder handBinder) { - Transform indexBone = handBinder.BoundHand.fingers[(int)Finger.FingerType.TYPE_INDEX].boundBones[(int)Bone.BoneType.TYPE_PROXIMAL].boundTransform; - Transform middleBone = handBinder.BoundHand.fingers[(int)Finger.FingerType.TYPE_MIDDLE].boundBones[(int)Bone.BoneType.TYPE_PROXIMAL].boundTransform; - Transform pinkyBone = handBinder.BoundHand.fingers[(int)Finger.FingerType.TYPE_PINKY].boundBones[(int)Bone.BoneType.TYPE_PROXIMAL].boundTransform; + Transform indexBone = handBinder.BoundHand.fingers[(int)Finger.FingerType.INDEX].boundBones[(int)Bone.BoneType.PROXIMAL].boundTransform; + Transform middleBone = handBinder.BoundHand.fingers[(int)Finger.FingerType.MIDDLE].boundBones[(int)Bone.BoneType.PROXIMAL].boundTransform; + Transform pinkyBone = handBinder.BoundHand.fingers[(int)Finger.FingerType.PINKY].boundBones[(int)Bone.BoneType.PROXIMAL].boundTransform; Transform wrist = handBinder.BoundHand.wrist.boundTransform; @@ -310,7 +310,7 @@ static void CalculateHandSize(BoundHand boundHand) bool AddedWristToFirstBone = false; - var finger = boundHand.fingers[(int)Finger.FingerType.TYPE_MIDDLE]; + var finger = boundHand.fingers[(int)Finger.FingerType.MIDDLE]; // Loop through the bones and sum up their lengths for (int boneID = 0; boneID < finger.boundBones.Length - 1; boneID++) @@ -341,7 +341,7 @@ static void CalculateFingerTipLengths(HandBinder handBinder) { var finger = handBinder.BoundHand.fingers[i]; var lastBone = finger.boundBones.LastOrDefault().boundTransform; - var previousBone = finger.boundBones[(int)Bone.BoneType.TYPE_INTERMEDIATE].boundTransform; + var previousBone = finger.boundBones[(int)Bone.BoneType.INTERMEDIATE].boundTransform; if (lastBone != null) { diff --git a/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderData.cs b/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderData.cs index 20fc4b9ceb..3c66d1ec48 100644 --- a/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderData.cs +++ b/Packages/Tracking/Hands/Runtime/Scripts/HandBinder/HandBinderData.cs @@ -111,26 +111,26 @@ public static class HandBinderUtilities /// public readonly static Dictionary boundTypeMapping = new Dictionary { - {BoundTypes.THUMB_METACARPAL, (Finger.FingerType.TYPE_THUMB, Bone.BoneType.TYPE_METACARPAL)}, - {BoundTypes.THUMB_PROXIMAL, (Finger.FingerType.TYPE_THUMB, Bone.BoneType.TYPE_PROXIMAL)}, - {BoundTypes.THUMB_INTERMEDIATE, (Finger.FingerType.TYPE_THUMB, Bone.BoneType.TYPE_INTERMEDIATE)}, - {BoundTypes.THUMB_DISTAL, (Finger.FingerType.TYPE_THUMB, Bone.BoneType.TYPE_DISTAL)}, - {BoundTypes.INDEX_METACARPAL, (Finger.FingerType.TYPE_INDEX, Bone.BoneType.TYPE_METACARPAL)}, - {BoundTypes.INDEX_PROXIMAL, (Finger.FingerType.TYPE_INDEX, Bone.BoneType.TYPE_PROXIMAL)}, - {BoundTypes.INDEX_INTERMEDIATE, (Finger.FingerType.TYPE_INDEX, Bone.BoneType.TYPE_INTERMEDIATE)}, - {BoundTypes.INDEX_DISTAL, (Finger.FingerType.TYPE_INDEX, Bone.BoneType.TYPE_DISTAL)}, - {BoundTypes.MIDDLE_METACARPAL, (Finger.FingerType.TYPE_MIDDLE, Bone.BoneType.TYPE_METACARPAL)}, - {BoundTypes.MIDDLE_PROXIMAL, (Finger.FingerType.TYPE_MIDDLE, Bone.BoneType.TYPE_PROXIMAL)}, - {BoundTypes.MIDDLE_INTERMEDIATE, (Finger.FingerType.TYPE_MIDDLE, Bone.BoneType.TYPE_INTERMEDIATE)}, - {BoundTypes.MIDDLE_DISTAL, (Finger.FingerType.TYPE_MIDDLE, Bone.BoneType.TYPE_DISTAL)}, - {BoundTypes.RING_METACARPAL, (Finger.FingerType.TYPE_RING, Bone.BoneType.TYPE_METACARPAL)}, - {BoundTypes.RING_PROXIMAL, (Finger.FingerType.TYPE_RING, Bone.BoneType.TYPE_PROXIMAL)}, - {BoundTypes.RING_INTERMEDIATE, (Finger.FingerType.TYPE_RING, Bone.BoneType.TYPE_INTERMEDIATE)}, - {BoundTypes.RING_DISTAL, (Finger.FingerType.TYPE_RING, Bone.BoneType.TYPE_DISTAL)}, - {BoundTypes.PINKY_METACARPAL, (Finger.FingerType.TYPE_PINKY, Bone.BoneType.TYPE_METACARPAL)}, - {BoundTypes.PINKY_PROXIMAL, (Finger.FingerType.TYPE_PINKY, Bone.BoneType.TYPE_PROXIMAL)}, - {BoundTypes.PINKY_INTERMEDIATE, (Finger.FingerType.TYPE_PINKY, Bone.BoneType.TYPE_INTERMEDIATE)}, - {BoundTypes.PINKY_DISTAL, (Finger.FingerType.TYPE_PINKY, Bone.BoneType.TYPE_DISTAL)}, + {BoundTypes.THUMB_METACARPAL, (Finger.FingerType.THUMB, Bone.BoneType.METACARPAL)}, + {BoundTypes.THUMB_PROXIMAL, (Finger.FingerType.THUMB, Bone.BoneType.PROXIMAL)}, + {BoundTypes.THUMB_INTERMEDIATE, (Finger.FingerType.THUMB, Bone.BoneType.INTERMEDIATE)}, + {BoundTypes.THUMB_DISTAL, (Finger.FingerType.THUMB, Bone.BoneType.DISTAL)}, + {BoundTypes.INDEX_METACARPAL, (Finger.FingerType.INDEX, Bone.BoneType.METACARPAL)}, + {BoundTypes.INDEX_PROXIMAL, (Finger.FingerType.INDEX, Bone.BoneType.PROXIMAL)}, + {BoundTypes.INDEX_INTERMEDIATE, (Finger.FingerType.INDEX, Bone.BoneType.INTERMEDIATE)}, + {BoundTypes.INDEX_DISTAL, (Finger.FingerType.INDEX, Bone.BoneType.DISTAL)}, + {BoundTypes.MIDDLE_METACARPAL, (Finger.FingerType.MIDDLE, Bone.BoneType.METACARPAL)}, + {BoundTypes.MIDDLE_PROXIMAL, (Finger.FingerType.MIDDLE, Bone.BoneType.PROXIMAL)}, + {BoundTypes.MIDDLE_INTERMEDIATE, (Finger.FingerType.MIDDLE, Bone.BoneType.INTERMEDIATE)}, + {BoundTypes.MIDDLE_DISTAL, (Finger.FingerType.MIDDLE, Bone.BoneType.DISTAL)}, + {BoundTypes.RING_METACARPAL, (Finger.FingerType.RING, Bone.BoneType.METACARPAL)}, + {BoundTypes.RING_PROXIMAL, (Finger.FingerType.RING, Bone.BoneType.PROXIMAL)}, + {BoundTypes.RING_INTERMEDIATE, (Finger.FingerType.RING, Bone.BoneType.INTERMEDIATE)}, + {BoundTypes.RING_DISTAL, (Finger.FingerType.RING, Bone.BoneType.DISTAL)}, + {BoundTypes.PINKY_METACARPAL, (Finger.FingerType.PINKY, Bone.BoneType.METACARPAL)}, + {BoundTypes.PINKY_PROXIMAL, (Finger.FingerType.PINKY, Bone.BoneType.PROXIMAL)}, + {BoundTypes.PINKY_INTERMEDIATE, (Finger.FingerType.PINKY, Bone.BoneType.INTERMEDIATE)}, + {BoundTypes.PINKY_DISTAL, (Finger.FingerType.PINKY, Bone.BoneType.DISTAL)}, }; /// @@ -144,10 +144,10 @@ public static Hand GenerateLeapHand(this BoundHand boundHand, Hand leapHand, flo } //Loop through all the fingers of the hand to calculate where the leap data should be in relation to the Bound Hand - for (int leapFingerID = 0; leapFingerID < leapHand.Fingers.Count; leapFingerID++) + for (int leapFingerID = 0; leapFingerID < leapHand.fingers.Length; leapFingerID++) { //Get the leap Finger - Finger leapFinger = leapHand.Fingers[leapFingerID]; + Finger leapFinger = leapHand.fingers[leapFingerID]; for (int leapBoneID = 0; leapBoneID < leapFinger.bones.Length; leapBoneID++) { @@ -155,7 +155,7 @@ public static Hand GenerateLeapHand(this BoundHand boundHand, Hand leapHand, flo Bone leapBone = leapFinger.bones[leapBoneID]; //If this bone is the distal bone, calculate a finger tip position - if (leapBoneID == (int)Bone.BoneType.TYPE_DISTAL) + if (leapBoneID == (int)Bone.BoneType.DISTAL) { BoundBone distalBoundBone = boundHand.fingers[leapFingerID].boundBones[leapBoneID]; BoundBone intermediateBoundBone = boundHand.fingers[leapFingerID].boundBones[leapBoneID - 1]; @@ -206,9 +206,9 @@ public static Hand GenerateLeapHand(this BoundHand boundHand, Hand leapHand, flo } //If the bone is a metacarpal, use the wrist bone as the previous joint - else if (leapBoneID == (int)Bone.BoneType.TYPE_METACARPAL) + else if (leapBoneID == (int)Bone.BoneType.METACARPAL) { - BoundBone proximalBoundBone = boundHand.fingers[leapFingerID].boundBones[(int)Bone.BoneType.TYPE_PROXIMAL]; + BoundBone proximalBoundBone = boundHand.fingers[leapFingerID].boundBones[(int)Bone.BoneType.PROXIMAL]; BoundBone wristBoundBone = boundHand.wrist; if (proximalBoundBone.boundTransform && wristBoundBone.boundTransform) @@ -249,12 +249,12 @@ public static Hand GenerateLeapHand(this BoundHand boundHand, Hand leapHand, flo } //Calculate the palm position half way between the wrist and the middle proximal bone - Vector3 palmPos = Vector3.Lerp(leapHand.WristPosition, leapHand.GetMiddle().bones[(int)Bone.BoneType.TYPE_PROXIMAL].PrevJoint, 0.5f); + Vector3 palmPos = Vector3.Lerp(leapHand.WristPosition, leapHand.Middle.bones[(int)Bone.BoneType.PROXIMAL].PrevJoint, 0.5f); //Set the data on the leap hand leapHand.PalmPosition = palmPos; leapHand.StabilizedPalmPosition = leapHand.PalmPosition; - leapHand.PalmWidth = (leapHand.GetPinky().bones[1].PrevJoint - leapHand.GetIndex().bones[1].PrevJoint).magnitude; + leapHand.PalmWidth = (leapHand.Pinky.bones[1].PrevJoint - leapHand.Index.bones[1].PrevJoint).magnitude; leapHand.Arm.NextJoint = leapHand.WristPosition; return leapHand; } diff --git a/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionBehaviour.cs b/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionBehaviour.cs index 10a660efe0..052cd28e76 100644 --- a/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionBehaviour.cs +++ b/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionBehaviour.cs @@ -168,7 +168,7 @@ public Finger primaryHoveringFinger { if (!isPrimaryHovered) return null; return _closestPrimaryHoveringHand.leapHand - .Fingers[_closestPrimaryHoveringHand.primaryHoveringPointIndex]; + .fingers[_closestPrimaryHoveringHand.primaryHoveringPointIndex]; } } diff --git a/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionController.cs b/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionController.cs index fd19decdab..ee0a2ffc96 100644 --- a/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionController.cs +++ b/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionController.cs @@ -589,7 +589,7 @@ private void processPrimaryHover(IInteractionBehaviour behaviour, float maxNewPr // Skip non-index fingers for InteractionHands if they aren't extended. if (intHand != null) { - if (!(intHand.leapHand).Fingers[i].IsExtended && i != 1) { continue; } + if (!(intHand.leapHand).fingers[i].IsExtended && i != 1) { continue; } } // Check primary hover for the primary hover point. diff --git a/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionHand.cs b/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionHand.cs index 1cc577fdfe..c0f9d88b50 100644 --- a/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionHand.cs +++ b/Packages/Tracking/Interaction Engine/Runtime/Scripts/InteractionHand.cs @@ -400,7 +400,7 @@ private void refreshPrimaryHoverPoints() { _fingertipTransforms[i] = _backingFingertipTransforms[i]; - Finger finger = leapHand.Fingers[i]; + Finger finger = leapHand.fingers[i]; _fingertipTransforms[i].position = finger.TipPosition; _fingertipTransforms[i].rotation = finger.bones[3].Rotation; } @@ -503,8 +503,8 @@ private void initContactBones() GameObject contactBoneObj = new GameObject("Contact Fingerbone", typeof(CapsuleCollider), typeof(Rigidbody), typeof(ContactBone)); contactBoneObj.layer = manager.contactBoneLayer; - Bone bone = _unwarpedHandData.Fingers[fingerIndex] - .Bone((Bone.BoneType)(jointIndex) + 1); // +1 to skip first bone. + Bone bone = _unwarpedHandData.fingers[fingerIndex] + .GetBone((Bone.BoneType)(jointIndex) + 1); // +1 to skip first bone. int boneArrayIndex = fingerIndex * BONES_PER_FINGER + jointIndex; contactBoneObj.transform.position = bone.Center; contactBoneObj.transform.rotation = bone.Rotation; @@ -517,7 +517,7 @@ private void initContactBones() out Vector3 targetPosition, out Quaternion targetRotation) => { - Bone theBone = hand.Fingers[fingerIndexCopy].Bone((Bone.BoneType)(jointIndexCopy + 1)); + Bone theBone = hand.fingers[fingerIndexCopy].GetBone((Bone.BoneType)(jointIndexCopy + 1)); targetPosition = theBone.Center; targetRotation = theBone.Rotation; }; @@ -544,7 +544,7 @@ private void initContactBones() // Palm is attached to the third metacarpal and derived from it. GameObject contactBoneObj = new GameObject("Contact Palm Bone", typeof(BoxCollider), typeof(Rigidbody), typeof(ContactBone)); - Bone bone = _unwarpedHandData.Fingers[(int)Finger.FingerType.TYPE_MIDDLE].Bone(Bone.BoneType.TYPE_METACARPAL); + Bone bone = _unwarpedHandData.fingers[(int)Finger.FingerType.MIDDLE].GetBone(Bone.BoneType.METACARPAL); int boneArrayIndex = NUM_FINGERS * BONES_PER_FINGER; contactBoneObj.transform.position = _unwarpedHandData.PalmPosition; contactBoneObj.transform.rotation = _unwarpedHandData.Rotation; @@ -612,14 +612,14 @@ private void addContactBoneJoints() { for (int jointIndex = 0; jointIndex < BONES_PER_FINGER; jointIndex++) { - Bone bone = _unwarpedHandData.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex) + 1); // +1 to skip first bone. + Bone bone = _unwarpedHandData.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex) + 1); // +1 to skip first bone. int boneArrayIndex = fingerIndex * BONES_PER_FINGER + jointIndex; FixedJoint joint = _contactBones[boneArrayIndex].gameObject.AddComponent(); joint.autoConfigureConnectedAnchor = false; if (jointIndex != 0) { - Bone prevBone = _unwarpedHandData.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex)); + Bone prevBone = _unwarpedHandData.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex)); joint.connectedBody = _contactBones[boneArrayIndex - 1].rigidbody; joint.anchor = Vector3.back * bone.Length / 2f; joint.connectedAnchor = Vector3.forward * prevBone.Length / 2f; @@ -655,7 +655,7 @@ private void resetContactBoneJoints() { for (int jointIndex = 0; jointIndex < BONES_PER_FINGER; jointIndex++) { - Bone bone = _unwarpedHandData.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex) + 1); // +1 to skip first bone. + Bone bone = _unwarpedHandData.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex) + 1); // +1 to skip first bone. int boneArrayIndex = fingerIndex * BONES_PER_FINGER + jointIndex; _contactBones[boneArrayIndex].transform.position = bone.Center; @@ -667,7 +667,7 @@ private void resetContactBoneJoints() if (jointIndex != 0 && _contactBones[boneArrayIndex].joint != null) { - Bone prevBone = _unwarpedHandData.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex)); + Bone prevBone = _unwarpedHandData.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex)); _contactBones[boneArrayIndex].joint.connectedBody = _contactBones[boneArrayIndex - 1].rigidbody; _contactBones[boneArrayIndex].joint.anchor = Vector3.back * bone.Length / 2f; _contactBones[boneArrayIndex].joint.connectedAnchor = Vector3.forward * prevBone.Length / 2f; @@ -699,7 +699,7 @@ public void FillBones(Hand inHand) { for (int jointIndex = 0; jointIndex < BONES_PER_FINGER; jointIndex++) { - Bone bone = inHand.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex) + 1); + Bone bone = inHand.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex) + 1); int boneArrayIndex = fingerIndex * BONES_PER_FINGER + jointIndex; Vector3 displacement = _contactBones[boneArrayIndex].rigidbody.position - bone.Center; bone.Center += displacement; @@ -743,7 +743,7 @@ private void refreshGraspManipulatorPoints() // Update or add knuckle-joint and first-finger-bone positions as the grasp // manipulator points for this Hand. - Vector3 point = leapHand.Fingers[i].bones[boneIdx].NextJoint; + Vector3 point = leapHand.fingers[i].bones[boneIdx].NextJoint; if (_graspManipulatorPoints.Count - 1 < bufferIndex) { @@ -907,7 +907,7 @@ public override void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (enabledPrimaryHoverFingertips[i]) { - drawPrimaryHoverPoint(drawer, _testHand.Fingers[i].TipPosition); + drawPrimaryHoverPoint(drawer, _testHand.fingers[i].TipPosition); } } } diff --git a/Packages/Tracking/Interaction Engine/Runtime/Scripts/Internal/HeuristicGrabClassifier.cs b/Packages/Tracking/Interaction Engine/Runtime/Scripts/Internal/HeuristicGrabClassifier.cs index f967f2fd71..a3896a8004 100644 --- a/Packages/Tracking/Interaction Engine/Runtime/Scripts/Internal/HeuristicGrabClassifier.cs +++ b/Packages/Tracking/Interaction Engine/Runtime/Scripts/Internal/HeuristicGrabClassifier.cs @@ -79,10 +79,10 @@ public void FixedUpdateClassifierHandState(Transform headTransform = null) // Ensure layer mask is up-to-date. _scaledGrabParams.LAYER_MASK = interactionHand.manager.GetInteractionLayerMask(); - for (int i = 0; i < hand.Fingers.Count; i++) + for (int i = 0; i < hand.fingers.Length; i++) { - _fingerTipPositions[i] = hand.Fingers[i].TipPosition; - _fingerKnucklePositions[i] = hand.Fingers[i].Bone(Bone.BoneType.TYPE_METACARPAL).NextJoint; + _fingerTipPositions[i] = hand.fingers[i].TipPosition; + _fingerKnucklePositions[i] = hand.fingers[i].GetBone(Bone.BoneType.METACARPAL).NextJoint; } GrabClassifierHeuristics.UpdateAllProbeColliders(_fingerTipPositions, _fingerKnucklePositions, ref _collidingCandidates, ref _numberOfColliders, _scaledGrabParams); @@ -261,9 +261,9 @@ protected void FillClassifier(IInteractionBehaviour behaviour, Hand hand, ref Gr classifier.handGrabCenter = (hand.PalmPosition + (hand.Direction * 0.05f * simScale) + (hand.PalmNormal * 0.01f * simScale)); - for (int i = 0; i < hand.Fingers.Count; i++) + for (int i = 0; i < hand.fingers.Length; i++) { - classifier.probes[i].direction = hand.Fingers[i].Direction; + classifier.probes[i].direction = hand.fingers[i].Direction; } classifier.isGrabbed = behaviour.isGrasped; } diff --git a/Packages/Tracking/OpenXR/Runtime/Scripts/OpenXRLeapProvider.cs b/Packages/Tracking/OpenXR/Runtime/Scripts/OpenXRLeapProvider.cs index 3586745d0c..822e8489c7 100644 --- a/Packages/Tracking/OpenXR/Runtime/Scripts/OpenXRLeapProvider.cs +++ b/Packages/Tracking/OpenXR/Runtime/Scripts/OpenXRLeapProvider.cs @@ -222,7 +222,7 @@ private bool PopulateLeapHandFromOpenXRJoints(HandTracker handTracker, ref Hand } // Populate the finger bone information - var bone = hand.Fingers[fingerIndex].bones[boneIndex]; + var bone = hand.fingers[fingerIndex].bones[boneIndex]; bone.Fill( prevJoint.Pose.position, nextJoint.Pose.position, @@ -234,12 +234,12 @@ private bool PopulateLeapHandFromOpenXRJoints(HandTracker handTracker, ref Hand prevJoint.Pose.rotation); fingerWidth = Mathf.Max(fingerWidth, bone.Width); - if (bone.Type == Bone.BoneType.TYPE_INTERMEDIATE) + if (bone.Type == Bone.BoneType.INTERMEDIATE) { xrIntermediateIndex = xrPrevIndex; } - if (bone.Type == Bone.BoneType.TYPE_DISTAL) + if (bone.Type == Bone.BoneType.DISTAL) { xrTipIndex = xrNextIndex; } @@ -252,7 +252,7 @@ private bool PopulateLeapHandFromOpenXRJoints(HandTracker handTracker, ref Hand } // Populate the higher - level finger data. - hand.Fingers[fingerIndex].Fill( + hand.fingers[fingerIndex].Fill( _frameId, (handTracker == HandTracker.Left ? 0 : 1), fingerIndex, diff --git a/Packages/Tracking/Physical Hands/Runtime/Scripts/ContactHand.cs b/Packages/Tracking/Physical Hands/Runtime/Scripts/ContactHand.cs index 27081c60c0..fe29a216d8 100644 --- a/Packages/Tracking/Physical Hands/Runtime/Scripts/ContactHand.cs +++ b/Packages/Tracking/Physical Hands/Runtime/Scripts/ContactHand.cs @@ -120,7 +120,7 @@ internal void UpdateHand(Hand hand) for (int i = 0; i < bones.Length; i++) { - bones[i].UpdateBone(hand.Fingers[bones[i].Finger].bones[bones[i].joint], hand.Fingers[bones[i].Finger].bones[bones[i].joint + 1]); + bones[i].UpdateBone(hand.fingers[bones[i].Finger].bones[bones[i].joint], hand.fingers[bones[i].Finger].bones[bones[i].joint + 1]); } CacheHandData(dataHand); @@ -205,11 +205,11 @@ internal void GenerateHandObjects(System.Type boneType) for (int fingerIndex = 0; fingerIndex < FINGERS; fingerIndex++) { lastTransform = palmBone.transform; - knuckleBone = leapHand.Fingers[fingerIndex].Bone((Bone.BoneType)(0)); + knuckleBone = leapHand.fingers[fingerIndex].GetBone((Bone.BoneType)(0)); for (int jointIndex = 0; jointIndex < FINGER_BONES; jointIndex++) { - prevBone = leapHand.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex)); + prevBone = leapHand.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex)); boneArrayIndex = fingerIndex * FINGER_BONES + jointIndex; @@ -222,7 +222,7 @@ internal void GenerateHandObjects(System.Type boneType) bone.joint = jointIndex; bone.boneCollider = bone.gameObject.AddComponent(); - ContactUtils.SetupBoneCollider(bone.boneCollider, leapHand.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex + 1))); + ContactUtils.SetupBoneCollider(bone.boneCollider, leapHand.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex + 1))); bone.contactHand = this; if (jointIndex == 0) diff --git a/Packages/Tracking/Physical Hands/Runtime/Scripts/Hard Contact/HardContactHand.cs b/Packages/Tracking/Physical Hands/Runtime/Scripts/Hard Contact/HardContactHand.cs index 4c5726af45..10e49ed43e 100644 --- a/Packages/Tracking/Physical Hands/Runtime/Scripts/Hard Contact/HardContactHand.cs +++ b/Packages/Tracking/Physical Hands/Runtime/Scripts/Hard Contact/HardContactHand.cs @@ -128,8 +128,8 @@ private void ResetHardContactHand() fingerStiffness[fingerIndex] = hardContactParent.boneStiffness; for (int jointIndex = 0; jointIndex < FINGER_BONES; jointIndex++) { - Bone prevBone = dataHand.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex)); - Bone bone = dataHand.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex + 1)); // +1 to skip first bone. + Bone prevBone = dataHand.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex)); + Bone bone = dataHand.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex + 1)); // +1 to skip first bone. int boneArrayIndex = fingerIndex * FINGER_BONES + jointIndex; @@ -187,7 +187,7 @@ private void CalculateDisplacementsAndLimits() { int boneArrayIndex = fingerIndex * FINGER_BONES + jointIndex; - Bone bone = dataHand.Fingers[fingerIndex].Bone((Bone.BoneType)(jointIndex + 1)); + Bone bone = dataHand.fingers[fingerIndex].GetBone((Bone.BoneType)(jointIndex + 1)); ((HardContactBone)bones[boneArrayIndex]).UpdateBoneDisplacement(bone); _overallFingerDisplacement += ((HardContactBone)bones[boneArrayIndex]).DisplacementAmount; @@ -331,15 +331,15 @@ protected override void ProcessOutputHand(ref Hand modifiedHand) float r; if (!_justGhosted) { - for (int i = 0; i < modifiedHand.Fingers.Count; i++) + for (int i = 0; i < modifiedHand.fingers.Length; i++) { - Bone b = modifiedHand.Fingers[i].bones[0]; + Bone b = modifiedHand.fingers[i].bones[0]; PhysExts.ToWorldSpaceCapsule(bones[boneInd].boneCollider, out posA, out posB, out r); b.NextJoint = posB; - for (int j = 1; j < modifiedHand.Fingers[i].bones.Length; j++) + for (int j = 1; j < modifiedHand.fingers[i].bones.Length; j++) { - b = modifiedHand.Fingers[i].bones[j]; + b = modifiedHand.fingers[i].bones[j]; PhysExts.ToWorldSpaceCapsule(bones[boneInd].boneCollider, out posA, out posB, out r); b.PrevJoint = posB; @@ -352,7 +352,7 @@ protected override void ProcessOutputHand(ref Hand modifiedHand) boneInd++; } - modifiedHand.Fingers[i].TipPosition = GetTipPosition(i); + modifiedHand.fingers[i].TipPosition = GetTipPosition(i); } } diff --git a/Packages/Tracking/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs b/Packages/Tracking/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs index 636501ff7f..e11a24c6e3 100644 --- a/Packages/Tracking/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs +++ b/Packages/Tracking/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs @@ -901,14 +901,14 @@ private bool DataHandIntersection(ContactHand hand) if (thumb) continue; - if (lHand.Fingers[bone.Finger].bones[bone.Joint].IsBoneWithinObject(_colliders)) + if (lHand.fingers[bone.Finger].bones[bone.Joint].IsBoneWithinObject(_colliders)) { thumb = true; earlyQuit = true; } break; case 1: // index - if (lHand.Fingers[bone.Finger].bones[bone.Joint].IsBoneWithinObject(_colliders)) + if (lHand.fingers[bone.Finger].bones[bone.Joint].IsBoneWithinObject(_colliders)) { otherFinger = true; earlyQuit = true; @@ -917,7 +917,7 @@ private bool DataHandIntersection(ContactHand hand) case 2: // middle case 3: // ring case 4: // pinky - if (bone.Joint == 2 && lHand.Fingers[bone.Finger].bones[bone.Joint].IsBoneWithinObject(_colliders)) + if (bone.Joint == 2 && lHand.fingers[bone.Finger].bones[bone.Joint].IsBoneWithinObject(_colliders)) { otherFinger = true; earlyQuit = true; diff --git a/Packages/Tracking/Physical Hands/Runtime/Scripts/Utils/ContactUtils.cs b/Packages/Tracking/Physical Hands/Runtime/Scripts/Utils/ContactUtils.cs index a732b6c358..dc11103c90 100644 --- a/Packages/Tracking/Physical Hands/Runtime/Scripts/Utils/ContactUtils.cs +++ b/Packages/Tracking/Physical Hands/Runtime/Scripts/Utils/ContactUtils.cs @@ -18,15 +18,15 @@ public static class ContactUtils internal static Vector3 CalculateAverageKnucklePosition(this Hand hand) { - return (hand.Fingers[1].bones[0].NextJoint + - hand.Fingers[2].bones[0].NextJoint + - hand.Fingers[3].bones[0].NextJoint + - hand.Fingers[4].bones[0].NextJoint) / 4; + return (hand.fingers[1].bones[0].NextJoint + + hand.fingers[2].bones[0].NextJoint + + hand.fingers[3].bones[0].NextJoint + + hand.fingers[4].bones[0].NextJoint) / 4; } internal static Vector3 CalculatePalmSize(Hand hand) { - return new Vector3(hand.PalmWidth, hand.Fingers[2].Bone(0).Width, Vector3.Distance(CalculateAverageKnucklePosition(hand), hand.WristPosition)); + return new Vector3(hand.PalmWidth, hand.fingers[2].GetBone(0).Width, Vector3.Distance(CalculateAverageKnucklePosition(hand), hand.WristPosition)); } internal static void SetupPalmCollider(BoxCollider collider, CapsuleCollider[] palmEdges, Hand hand, PhysicMaterial material = null)