MCPcopy Create free account
hub / github.com/LibreVR/Revive / ovr_GetTrackerPose

Function ovr_GetTrackerPose

ReviveXR/REV_CAPI.cpp:445–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445OVR_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
490typedef struct ovrInputState1_

Callers

nothing calls this directly

Calls 4

QuatfClass · 0.85
ovr_GetTrackerCountFunction · 0.70
PosefClass · 0.70
Vector3fClass · 0.70

Tested by

no test coverage detected