| 170 | } |
| 171 | |
| 172 | void InputManager::GetTrackingState(ovrSession session, ovrTrackingState* outState, double absTime) |
| 173 | { |
| 174 | double calledTime = absTime; |
| 175 | |
| 176 | if (!session->Session) |
| 177 | return; |
| 178 | |
| 179 | if (absTime <= 0.0) |
| 180 | absTime = ovr_GetTimeInSeconds(); |
| 181 | |
| 182 | XrSpaceLocation location = XR_TYPE(SPACE_LOCATION); |
| 183 | XrSpaceVelocity velocity = XR_TYPE(SPACE_VELOCITY); |
| 184 | location.next = &velocity; |
| 185 | XrTime displayTime = AbsTimeToXrTime(session->Instance, absTime); |
| 186 | XrSpace space = session->TrackingSpaces[session->TrackingOrigin]; |
| 187 | |
| 188 | // Get the head space location |
| 189 | if (XR_FAILED(xrLocateSpace(session->ViewSpace, space, displayTime, &location))) |
| 190 | xrLocateSpace(session->ViewSpace, space, (*session->CurrentFrame).predictedDisplayTime, &location); |
| 191 | outState->StatusFlags = SpaceRelationToPoseState(location, absTime, m_LastTrackingState.HeadPose, outState->HeadPose); |
| 192 | |
| 193 | // Get the hand space locations |
| 194 | for (uint32_t i = 0; i < ovrHand_Count && i < m_ActionSpaces.size(); i++) |
| 195 | { |
| 196 | XrSpaceLocation handLocation = XR_TYPE(SPACE_LOCATION); |
| 197 | handLocation.next = &velocity; |
| 198 | if (XR_FAILED(xrLocateSpace(m_ActionSpaces[i], space, displayTime, &handLocation))) |
| 199 | xrLocateSpace(m_ActionSpaces[i], space, (*session->CurrentFrame).predictedDisplayTime, &handLocation); |
| 200 | outState->HandStatusFlags[i] = SpaceRelationToPoseState(handLocation, absTime, m_LastTrackingState.HandPoses[i], outState->HandPoses[i]); |
| 201 | } |
| 202 | |
| 203 | XrSpace origin = session->OriginSpaces[session->TrackingOrigin]; |
| 204 | location.next = nullptr; |
| 205 | if (XR_FAILED(xrLocateSpace(space, origin, displayTime, &location))) |
| 206 | xrLocateSpace(space, origin, (*session->CurrentFrame).predictedDisplayTime, &location); |
| 207 | |
| 208 | if (location.locationFlags & (XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT)) |
| 209 | outState->CalibratedOrigin = XR::Posef(location.pose); |
| 210 | else |
| 211 | outState->CalibratedOrigin = OVR::Posef::Identity(); |
| 212 | |
| 213 | m_LastTrackingState = *outState; |
| 214 | } |
| 215 | |
| 216 | ovrResult InputManager::GetDevicePoses(ovrSession session, ovrTrackedDeviceType* deviceTypes, int deviceCount, double absTime, ovrPoseStatef* outDevicePoses) |
| 217 | { |
no test coverage detected