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

Method GetTrackingState

ReviveXR/InputManager.cpp:172–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void 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
216ovrResult InputManager::GetDevicePoses(ovrSession session, ovrTrackedDeviceType* deviceTypes, int deviceCount, double absTime, ovrPoseStatef* outDevicePoses)
217{

Callers 1

ovr_GetTrackingStateFunction · 0.45

Calls 4

AbsTimeToXrTimeFunction · 0.85
sizeMethod · 0.80
ovr_GetTimeInSecondsFunction · 0.70
PosefClass · 0.70

Tested by

no test coverage detected