diff --git a/Runtime/HumanoidControl/Scripts/Extensions/Oculus/OculusHandSkeleton.cs b/Runtime/HumanoidControl/Scripts/Extensions/Oculus/OculusHandSkeleton.cs index 28ce1e7..55d4415 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/Oculus/OculusHandSkeleton.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/Oculus/OculusHandSkeleton.cs @@ -86,7 +86,7 @@ namespace Passer.Tracking { } if (OculusDevice.GetHandState(OculusDevice.Step.Render, isLeft ? OculusDevice.Hand.HandLeft : OculusDevice.Hand.HandRight, ref handState)) { - if (handState.Status == 0) { + if ((handState.Status & OculusDevice.HandStatus.HandTracked) == 0) { status = Tracker.Status.Present; DisableRenderer(); return; diff --git a/Runtime/Tools/Scripts/InteractionModule.cs b/Runtime/Tools/Scripts/InteractionModule.cs index 7e94c32..e081cd8 100644 --- a/Runtime/Tools/Scripts/InteractionModule.cs +++ b/Runtime/Tools/Scripts/InteractionModule.cs @@ -112,7 +112,7 @@ namespace Passer { // This is not working, because Unity may set this to the wrong object autonomously //touchedObject = data.pointerCurrentRaycast.gameObject; //if (touchedObject == null) {// object is a 3D object, as we do not use Physicsraycaster, use the focusObject - touchedObject = focusObject; + touchedObject = focusObject; //} DebugLog("Touch " + touchedObject); @@ -121,8 +121,10 @@ namespace Passer { focusing = true; return; - } + else + ProcessFocus(); + if (!clicking) { // first activation touchedObject = data.pointerCurrentRaycast.gameObject; if (touchedObject == null) // object is a 3D object, as we do not use Physicsraycaster, use the focusObject @@ -528,18 +530,15 @@ namespace Passer { if (Camera.main == null || pointer.type != PointerType.Touch) return; - //if (eventSystem == null) - // eventSystem = Object.FindObjectOfType(); - //if (eventSystem == null) - // return; - pointer.data.position = Camera.main.WorldToScreenPoint(pointer.pointerTransform.position); + float distanceToPointer = Vector3.Distance(Camera.main.transform.position, pointer.pointerTransform.position); System.Collections.Generic.List m_RaycastResultCache = new System.Collections.Generic.List(); eventSystem.RaycastAll(pointer.data, m_RaycastResultCache); - RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache); + RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache, distanceToPointer); m_RaycastResultCache.Clear(); + if (raycastResult.gameObject != null) { if (pointer.type == PointerType.Touch) { float distance = DistanceTipToTransform(pointer.pointerTransform, raycastResult.gameObject.transform); @@ -559,9 +558,12 @@ namespace Passer { } } - private new RaycastResult FindFirstRaycast(System.Collections.Generic.List raycastResults) { + private RaycastResult FindFirstRaycast(System.Collections.Generic.List raycastResults, float pointerDistance) { foreach (RaycastResult result in raycastResults) { - if (result.isValid && result.worldPosition != Vector3.zero) { + float resultDistance = Vector3.Distance(Camera.main.transform.position, result.worldPosition); + if (result.isValid && + result.worldPosition != Vector3.zero && + Mathf.Abs(resultDistance - pointerDistance) < 0.02F) { return result; } } @@ -580,7 +582,6 @@ namespace Passer { } private float DistanceTipToTransform(Transform fingerTip, Transform transform) { - //Debug.DrawLine(fingerTip.position, transform.position); return (-transform.InverseTransformPoint(fingerTip.position).z * transform.lossyScale.z) - 0.01F; } }