From 77aa53bb8d651ed9518eed4da3375f60f82baa7a Mon Sep 17 00:00:00 2001 From: Jonathon Cobb Date: Wed, 8 Sep 2021 14:46:44 -0700 Subject: [PATCH 1/3] Add option to move grasp point to fingertip The grasp pointer by default is positioned between the thumb and index finger. However this is confusing if a fingertip cursor is rendered (either because one is added to the grasp pointer or because grabbable elements are near pokable ones). This adds an option to move the grasp point to the fingertip if desired. --- .../UX/Scripts/Pointers/SpherePointer.cs | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs b/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs index a0c6efd8e09..1beec39137b 100644 --- a/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs +++ b/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs @@ -8,6 +8,12 @@ namespace Microsoft.MixedReality.Toolkit.Input { + public enum GraspPointPlacement + { + BetweenFingerAndThumb, + Fingertip, + } + [AddComponentMenu("Scripts/MRTK/SDK/SpherePointer")] public class SpherePointer : BaseControllerPointer, IMixedRealityNearPointer { @@ -155,10 +161,19 @@ public override LayerMask[] PrioritizedLayerMasksOverride [Tooltip("Whether to ignore colliders that may be near the pointer, but not actually in the visual FOV. This can prevent accidental grabs, and will allow hand rays to turn on when you may be near a grabbable but cannot see it. Visual FOV is defined by cone centered about display center, radius equal to half display height.")] private bool ignoreCollidersNotInFOV = true; + [SerializeField] + [Tooltip("Location on the hand where a grasp is triggered (apllies to IMixedRealityHand only)")] + private GraspPointPlacement graspPointPlacement = GraspPointPlacement.BetweenFingerAndThumb; + + /// + /// Location on the hand where a grasp is triggered (apllies to IMixedRealityHand only) + /// + public GraspPointPlacement GraspPointPlacement => graspPointPlacement; + /// /// Whether to ignore colliders that may be near the pointer, but not actually in the visual FOV. - /// This can prevent accidental grabs, and will allow hand rays to turn on when you may be near - /// a grabbable but cannot see it. Visual FOV is defined by cone centered about display center, + /// This can prevent accidental grabs, and will allow hand rays to turn on when you may be near + /// a grabbable but cannot see it. Visual FOV is defined by cone centered about display center, /// radius equal to half display height. /// public bool IgnoreCollidersNotInFOV @@ -265,7 +280,7 @@ public override bool OnSceneQuery(LayerMask[] prioritizedLayerMasks, bool focusI /// /// Gets the position of where grasp happens - /// For IMixedRealityHand it's the average of index and thumb. + /// For IMixedRealityHand it's determined by (either the average of index and thumb or the fingertip). /// For any other IMixedRealityController, return just the pointer origin /// public bool TryGetNearGraspPoint(out Vector3 result) @@ -279,10 +294,19 @@ public bool TryGetNearGraspPoint(out Vector3 result) { if (hand.TryGetJoint(TrackedHandJoint.IndexTip, out MixedRealityPose index) && index != null) { - if (hand.TryGetJoint(TrackedHandJoint.ThumbTip, out MixedRealityPose thumb) && thumb != null) + switch (GraspPointPlacement) { - result = 0.5f * (index.Position + thumb.Position); - return true; + case GraspPointPlacement.BetweenFingerAndThumb: + if (hand.TryGetJoint(TrackedHandJoint.ThumbTip, out MixedRealityPose thumb) && thumb != null) + { + result = 0.5f * (index.Position + thumb.Position); + return true; + } + break; + + case GraspPointPlacement.Fingertip: + result = index.Position; + return true; } } } @@ -305,7 +329,7 @@ public bool TryGetNearGraspPoint(out Vector3 result) /// /// Because pointers shouldn't be able to interact with objects that are "behind" it, it is necessary to determine the forward axis of the pointer when making interaction checks. - /// + /// /// For example, a grab pointer's axis should is the result of Vector3.Lerp(palm forward axis, palm to index finger axis). /// /// This method provides a mechanism to get this normalized forward axis. @@ -385,7 +409,7 @@ public bool TryGetNormalToNearestSurface(out Vector3 normal) private class SpherePointerQueryInfo { /// - /// How many colliders are near the point from the latest call to TryUpdateQueryBufferForLayerMask + /// How many colliders are near the point from the latest call to TryUpdateQueryBufferForLayerMask /// private int numColliders; @@ -420,7 +444,7 @@ private class SpherePointerQueryInfo public bool ignoreBoundsHandlesForQuery = false; /// - /// The grabbable near the QueryRadius. + /// The grabbable near the QueryRadius. /// public NearInteractionGrabbable grabbable; From 5adcdc06a3410f5bbb9c36cd1590dd272e1ad558 Mon Sep 17 00:00:00 2001 From: RogPodge <39840334+RogPodge@users.noreply.github.com> Date: Fri, 10 Sep 2021 10:16:57 -0700 Subject: [PATCH 2/3] Update Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs --- Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs b/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs index 1beec39137b..f722dba42ca 100644 --- a/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs +++ b/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs @@ -409,7 +409,7 @@ public bool TryGetNormalToNearestSurface(out Vector3 normal) private class SpherePointerQueryInfo { /// - /// How many colliders are near the point from the latest call to TryUpdateQueryBufferForLayerMask + /// How many colliders are near the point from the latest call to TryUpdateQueryBufferForLayerMask. /// private int numColliders; From d1814acc380f89815e238825ef74f05d34e7b0b8 Mon Sep 17 00:00:00 2001 From: Jonathon Cobb Date: Wed, 29 Sep 2021 13:14:15 -0700 Subject: [PATCH 3/3] Remove public accessor for GraspPointPlacement --- .../UX/Scripts/Pointers/SpherePointer.cs | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs b/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs index f722dba42ca..762ebd63a3c 100644 --- a/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs +++ b/Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs @@ -8,15 +8,15 @@ namespace Microsoft.MixedReality.Toolkit.Input { - public enum GraspPointPlacement - { - BetweenFingerAndThumb, - Fingertip, - } - [AddComponentMenu("Scripts/MRTK/SDK/SpherePointer")] public class SpherePointer : BaseControllerPointer, IMixedRealityNearPointer { + private enum GraspPointPlacement + { + BetweenIndexFingerAndThumb, + IndexFingertip, + } + private SceneQueryType raycastMode = SceneQueryType.SphereOverlap; /// @@ -163,12 +163,7 @@ public override LayerMask[] PrioritizedLayerMasksOverride [SerializeField] [Tooltip("Location on the hand where a grasp is triggered (apllies to IMixedRealityHand only)")] - private GraspPointPlacement graspPointPlacement = GraspPointPlacement.BetweenFingerAndThumb; - - /// - /// Location on the hand where a grasp is triggered (apllies to IMixedRealityHand only) - /// - public GraspPointPlacement GraspPointPlacement => graspPointPlacement; + private GraspPointPlacement graspPointPlacement = GraspPointPlacement.BetweenIndexFingerAndThumb; /// /// Whether to ignore colliders that may be near the pointer, but not actually in the visual FOV. @@ -280,7 +275,7 @@ public override bool OnSceneQuery(LayerMask[] prioritizedLayerMasks, bool focusI /// /// Gets the position of where grasp happens - /// For IMixedRealityHand it's determined by (either the average of index and thumb or the fingertip). + /// For IMixedRealityHand it's determined by (either the average of index and thumb or the fingertip). /// For any other IMixedRealityController, return just the pointer origin /// public bool TryGetNearGraspPoint(out Vector3 result) @@ -294,9 +289,9 @@ public bool TryGetNearGraspPoint(out Vector3 result) { if (hand.TryGetJoint(TrackedHandJoint.IndexTip, out MixedRealityPose index) && index != null) { - switch (GraspPointPlacement) + switch (graspPointPlacement) { - case GraspPointPlacement.BetweenFingerAndThumb: + case GraspPointPlacement.BetweenIndexFingerAndThumb: if (hand.TryGetJoint(TrackedHandJoint.ThumbTip, out MixedRealityPose thumb) && thumb != null) { result = 0.5f * (index.Position + thumb.Position); @@ -304,7 +299,7 @@ public bool TryGetNearGraspPoint(out Vector3 result) } break; - case GraspPointPlacement.Fingertip: + case GraspPointPlacement.IndexFingertip: result = index.Position; return true; }