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

Method UpdateTrackerDesc

Revive/Session.cpp:241–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void ovrHmdStruct::UpdateTrackerDesc()
242{
243 const bool spoofSensors = UseHack(HACK_SPOOF_SENSORS);
244 vr::TrackedDeviceIndex_t trackers[vr::k_unMaxTrackedDeviceCount];
245 uint32_t count = 3;
246
247 if (!spoofSensors)
248 count = vr::VRSystem()->GetSortedTrackedDeviceIndicesOfClass(vr::TrackedDeviceClass_TrackingReference, trackers, vr::k_unMaxTrackedDeviceCount);
249
250 // Only update trackers we haven't seen yet, this ensures we don't run into concurrency errors
251 for (uint32_t i = TrackerCount; i < count; i++)
252 {
253 ovrTrackerDesc& desc = TrackerDesc[i];
254
255 if (spoofSensors)
256 {
257 desc.FrustumHFovInRadians = OVR::DegreeToRad(100.0f);
258 desc.FrustumVFovInRadians = OVR::DegreeToRad(70.0f);
259 desc.FrustumNearZInMeters = 0.4f;
260 desc.FrustumFarZInMeters = 2.5f;
261 }
262 else
263 {
264 vr::TrackedDeviceIndex_t index = trackers[i];
265
266 // Calculate field-of-view.
267 float left = vr::VRSystem()->GetFloatTrackedDeviceProperty(index, vr::Prop_FieldOfViewLeftDegrees_Float);
268 float right = vr::VRSystem()->GetFloatTrackedDeviceProperty(index, vr::Prop_FieldOfViewRightDegrees_Float);
269 float top = vr::VRSystem()->GetFloatTrackedDeviceProperty(index, vr::Prop_FieldOfViewTopDegrees_Float);
270 float bottom = vr::VRSystem()->GetFloatTrackedDeviceProperty(index, vr::Prop_FieldOfViewBottomDegrees_Float);
271 desc.FrustumHFovInRadians = (float)OVR::DegreeToRad(left + right);
272 desc.FrustumVFovInRadians = (float)OVR::DegreeToRad(top + bottom);
273
274 // Get the tracking frustum.
275 desc.FrustumNearZInMeters = vr::VRSystem()->GetFloatTrackedDeviceProperty(index, vr::Prop_TrackingRangeMinimumMeters_Float);
276 desc.FrustumFarZInMeters = vr::VRSystem()->GetFloatTrackedDeviceProperty(index, vr::Prop_TrackingRangeMaximumMeters_Float);
277 }
278 }
279
280 // Update the tracker count, this also serves as a memory barrier for the array
281 TrackerCount = count;
282}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected