| 280 | } |
| 281 | |
| 282 | ovrResult ovrHmdStruct::RecenterSpace(ovrTrackingOrigin origin, XrSpace anchor, ovrPosef offset) |
| 283 | { |
| 284 | std::lock_guard<std::shared_mutex> lk(TrackingMutex); |
| 285 | XrSpaceLocation location = XR_TYPE(SPACE_LOCATION); |
| 286 | CHK_XR(xrLocateSpace(anchor, OriginSpaces[origin], (*CurrentFrame).predictedDisplayTime, &location)); |
| 287 | |
| 288 | if (!(location.locationFlags & (XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT))) |
| 289 | return ovrError_InvalidHeadsetOrientation; |
| 290 | |
| 291 | // Get the yaw orientation from the view pose |
| 292 | float yaw; |
| 293 | XR::Quatf(location.pose.orientation).GetYawPitchRoll(&yaw, nullptr, nullptr); |
| 294 | |
| 295 | // Construct the new origin pose |
| 296 | XR::Posef newOrigin(OVR::Quatf(OVR::Axis_Y, yaw), XR::Vector3f(location.pose.position)); |
| 297 | |
| 298 | // For floor level spaces we keep the height at the floor |
| 299 | if (origin == ovrTrackingOrigin_FloorLevel) |
| 300 | newOrigin.Translation.y = 0.0f; |
| 301 | |
| 302 | // Replace the tracking space with the newly calibrated one |
| 303 | XrReferenceSpaceCreateInfo spaceInfo = XR_TYPE(REFERENCE_SPACE_CREATE_INFO); |
| 304 | spaceInfo.referenceSpaceType = static_cast<XrReferenceSpaceType>(XR_REFERENCE_SPACE_TYPE_LOCAL + origin); |
| 305 | spaceInfo.poseInReferenceSpace = XR::Posef(newOrigin * offset); |
| 306 | CHK_XR(xrDestroySpace(TrackingSpaces[origin])); |
| 307 | CHK_XR(xrCreateReferenceSpace(Session, &spaceInfo, &TrackingSpaces[origin])); |
| 308 | return ovrSuccess; |
| 309 | } |
| 310 | |
| 311 | bool ovrHmdStruct::SupportsFormat(int64_t format) const |
| 312 | { |
no test coverage detected