private static Ray CalculateProjectedSafeZoneRay(Vector3 origin, IMixedRealityController hand, SolverSafeZone handSafeZone) { Vector3 direction; switch (handSafeZone) { default: case SolverSafeZone.UlnarSide: { direction = Vector3.Cross(CameraCache.Main.transform.forward, Vector3.up); direction = IsPalmFacingCamera(hand) ? direction : -direction; if (hand.ControllerHandedness == Handedness.Left) { direction = -direction; } } break; case SolverSafeZone.RadialSide: { direction = Vector3.Cross(CameraCache.Main.transform.forward, Vector3.up); direction = IsPalmFacingCamera(hand) ? direction : -direction; if (hand.ControllerHandedness == Handedness.Right) { direction = -direction; } } break; case SolverSafeZone.AboveFingerTips: { direction = CameraCache.Main.transform.up; } break; case SolverSafeZone.BelowWrist: { direction = -CameraCache.Main.transform.up; } break; } return(new Ray(origin + direction, -direction)); }
private static Ray CalculateProjectedSafeZoneRay(Vector3 origin, Transform targetTransform, IMixedRealityController hand, SolverSafeZone handSafeZone, SolverRotationBehavior rotationBehavior) { Vector3 direction; switch (handSafeZone) { default: case SolverSafeZone.UlnarSide: { if (rotationBehavior == SolverRotationBehavior.LookAtTrackedObject) { direction = targetTransform.right; } else { direction = Vector3.Cross(CameraCache.Main.transform.forward, Vector3.up); direction = IsPalmFacingCamera(hand) ? direction : -direction; } if (hand.ControllerHandedness.IsLeft()) { direction = -direction; } } break; case SolverSafeZone.RadialSide: { if (rotationBehavior == SolverRotationBehavior.LookAtTrackedObject) { direction = -targetTransform.right; } else { direction = Vector3.Cross(CameraCache.Main.transform.forward, Vector3.up); direction = IsPalmFacingCamera(hand) ? direction : -direction; } if (hand.ControllerHandedness == Handedness.Right) { direction = -direction; } } break; case SolverSafeZone.AboveFingerTips: { direction = CameraCache.Main.transform.up; } break; case SolverSafeZone.BelowWrist: { direction = -CameraCache.Main.transform.up; } break; } return(new Ray(origin + direction, -direction)); }