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

Function ovr_TestBoundary

Revive/REV_CAPI.cpp:593–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591}
592
593OVR_PUBLIC_FUNCTION(ovrResult) ovr_TestBoundary(ovrSession session, ovrTrackedDeviceType deviceBitmask,
594 ovrBoundaryType boundaryType, ovrBoundaryTestResult* outTestResult)
595{
596 REV_TRACE(ovr_TestBoundary);
597
598 outTestResult->ClosestDistance = INFINITY;
599
600 vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount];
601 vr::VRCompositor()->GetLastPoses(poses, vr::k_unMaxTrackedDeviceCount, nullptr, 0);
602
603 if (vr::VRChaperone()->GetCalibrationState() != vr::ChaperoneCalibrationState_OK)
604 return ovrSuccess_BoundaryInvalid;
605
606 if (deviceBitmask & ovrTrackedDevice_HMD)
607 {
608 ovrBoundaryTestResult result = { 0 };
609 REV::Matrix4f matrix = (REV::Matrix4f)poses[vr::k_unTrackedDeviceIndex_Hmd].mDeviceToAbsoluteTracking;
610 ovrVector3f point = matrix.GetTranslation();
611
612 ovrResult err = ovr_TestBoundaryPoint(session, &point, boundaryType, &result);
613 if (OVR_SUCCESS(err) && result.ClosestDistance < outTestResult->ClosestDistance)
614 *outTestResult = result;
615 }
616
617
618 vr::TrackedDeviceIndex_t hands[] = { vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_LeftHand),
619 vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_RightHand) };
620
621 for (int i = 0; i < ovrHand_Count; i++)
622 {
623 if (deviceBitmask & (ovrTrackedDevice_LTouch << i))
624 {
625 ovrBoundaryTestResult result = { 0 };
626 if (hands[i] != vr::k_unTrackedDeviceIndexInvalid)
627 {
628 REV::Matrix4f matrix = (REV::Matrix4f)poses[hands[i]].mDeviceToAbsoluteTracking;
629 ovrVector3f point = matrix.GetTranslation();
630
631 ovrResult err = ovr_TestBoundaryPoint(session, &point, boundaryType, &result);
632 if (OVR_SUCCESS(err) && result.ClosestDistance < outTestResult->ClosestDistance)
633 *outTestResult = result;
634 }
635 }
636 }
637
638 return ovrSuccess;
639}
640
641OVR_PUBLIC_FUNCTION(ovrResult) ovr_TestBoundaryPoint(ovrSession session, const ovrVector3f* point,
642 ovrBoundaryType singleBoundaryType, ovrBoundaryTestResult* outTestResult)

Callers

nothing calls this directly

Calls 1

ovr_TestBoundaryPointFunction · 0.70

Tested by

no test coverage detected