| 443 | } |
| 444 | |
| 445 | OVR_PUBLIC_FUNCTION(ovrTrackerPose) ovr_GetTrackerPose(ovrSession session, unsigned int trackerPoseIndex) |
| 446 | { |
| 447 | REV_TRACE(ovr_GetTrackerPose); |
| 448 | |
| 449 | ovrTrackerPose tracker = { 0 }; |
| 450 | |
| 451 | if (!session) |
| 452 | return tracker; |
| 453 | |
| 454 | if (trackerPoseIndex < ovr_GetTrackerCount(session)) |
| 455 | { |
| 456 | const OVR::Posef poses[] = { |
| 457 | OVR::Posef(OVR::Quatf(OVR::Axis_Y, OVR::DegreeToRad(90.0f)), OVR::Vector3f(-2.0f, 0.0f, 0.2f)), |
| 458 | OVR::Posef(OVR::Quatf(OVR::Axis_Y, OVR::DegreeToRad(0.0f)), OVR::Vector3f(-0.2f, 0.0f, -2.0f)), |
| 459 | OVR::Posef(OVR::Quatf(OVR::Axis_Y, OVR::DegreeToRad(180.0f)), OVR::Vector3f(0.2f, 0.0f, 2.0f)) |
| 460 | }; |
| 461 | OVR::Posef trackerPose = poses[trackerPoseIndex]; |
| 462 | |
| 463 | std::shared_lock<std::shared_mutex> lk(session->TrackingMutex); |
| 464 | XrSpaceLocation relation = XR_TYPE(SPACE_LOCATION); |
| 465 | if (session->Session && XR_SUCCEEDED(xrLocateSpace(session->ViewSpace, session->TrackingSpaces[ovrTrackingOrigin_EyeLevel], |
| 466 | (*session->CurrentFrame).predictedDisplayTime, &relation))) |
| 467 | { |
| 468 | // Create a leveled head pose |
| 469 | if (relation.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) |
| 470 | { |
| 471 | float yaw; |
| 472 | XR::Posef headPose(relation.pose); |
| 473 | headPose.Rotation.GetYawPitchRoll(&yaw, nullptr, nullptr); |
| 474 | headPose.Rotation = OVR::Quatf(OVR::Axis_Y, yaw); |
| 475 | |
| 476 | // Rotate the trackers with the headset so that the headset is always in view |
| 477 | trackerPose = headPose * trackerPose; |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | tracker.Pose = trackerPose; |
| 482 | tracker.LeveledPose = trackerPose; |
| 483 | tracker.TrackerFlags = ovrTracker_Connected | ovrTracker_PoseTracked; |
| 484 | } |
| 485 | |
| 486 | return tracker; |
| 487 | } |
| 488 | |
| 489 | // Pre-1.7 input state |
| 490 | typedef struct ovrInputState1_ |
nothing calls this directly
no test coverage detected