protected virtual void ComputeBestSnapAddress(ref SnapAddress snapAddress) { IEnumerable<HandGrabInteractable> interactables = HandGrabInteractable.Registry.List(this); float bestFingerScore = -1f; float bestPoseScore = -1f; foreach (HandGrabInteractable interactable in interactables) { float fingerScore = 1.0f; if (!HandGrab.ComputeShouldSelect(this, interactable, out GrabTypeFlags selectingGrabTypes)) { fingerScore = HandGrab.ComputeHandGrabScore(this, interactable, out selectingGrabTypes); } if (fingerScore < bestFingerScore) { continue; } bool usePinchPoint = CanSnapToPinchPoint(interactable, selectingGrabTypes); Pose grabPoint = usePinchPoint ? _trackedPinchPose : _trackedGripPose; bool poseFound = interactable.CalculateBestPose(grabPoint, Hand.Scale, Hand.Handedness, ref _cachedBestHandPose, ref _cachedBestSnapPoint, out bool usesHandPose, out float poseScore); if (!poseFound) { continue; } if (fingerScore > bestFingerScore || poseScore > bestPoseScore) { bestFingerScore = fingerScore; bestPoseScore = poseScore; HandPose handPose = usesHandPose ? _cachedBestHandPose : null; snapAddress.Set(interactable, handPose, _cachedBestSnapPoint, usePinchPoint); } } if (bestFingerScore < 0) { snapAddress.Clear(); } }
/// <summary> /// Finds the best valid hand-pose at this HandGrabInteractable. /// Remember that a HandGrabPoint can actually have a whole surface the user can snap to. /// </summary> /// <param name="userPose">Pose to compare to the snap point in world coordinates.</param> /// <param name="handScale">The scale of the tracked hand.</param> /// <param name="handedness">The handedness of the tracked hand.</param> /// <param name="bestHandPose">The most similar valid HandPose at this HandGrabInteractable.</param> /// <param name="bestSnapPoint">The point of the valid snap.</param> /// <param name="scoringModifier">Parameters indicating how to score the different poses.</param> /// <param name="usesHandPose">True if the resultHandPose was populated.</param> /// <param name="score">The score of the best pose found.</param> /// <returns>True if a good pose was found</returns> public bool FindBestPose(Pose userPose, float handScale, Handedness handedness, ref HandPose bestHandPose, ref Pose bestSnapPoint, in PoseMeasureParameters scoringModifier, out bool usesHandPose, out float score)
public void Set(TSnappable snapInteractable, HandPose pose, in Pose snapPoint, bool usedPinchPoint)