Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: device/vr/openvr/openvr_device.cc

Issue 2829233003: Read poses relative to the seated zero pose for OpenVR (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _USE_MATH_DEFINES // for M_PI 5 #define _USE_MATH_DEFINES // for M_PI
6 #include "device/vr/openvr/openvr_device.h" 6 #include "device/vr/openvr/openvr_device.h"
7 #include <math.h> 7 #include <math.h>
8 #include "third_party/openvr/src/headers/openvr.h" 8 #include "third_party/openvr/src/headers/openvr.h"
9 9
10 namespace { 10 namespace {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 pose->orientation.value()[3] = 1; 209 pose->orientation.value()[3] = 1;
210 210
211 pose->position.emplace(3); 211 pose->position.emplace(3);
212 pose->position.value()[0] = 0; 212 pose->position.value()[0] = 0;
213 pose->position.value()[1] = 0; 213 pose->position.value()[1] = 0;
214 pose->position.value()[2] = 0; 214 pose->position.value()[2] = 0;
215 215
216 vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; 216 vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount];
217 217
218 vr_system_->GetDeviceToAbsoluteTrackingPose( 218 vr_system_->GetDeviceToAbsoluteTrackingPose(
219 vr::TrackingUniverseStanding, 0.0f, poses, vr::k_unMaxTrackedDeviceCount); 219 vr::TrackingUniverseSeated, 0.0f, poses, vr::k_unMaxTrackedDeviceCount);
220 const auto& hmdPose = poses[vr::k_unTrackedDeviceIndex_Hmd]; 220 const auto& hmdPose = poses[vr::k_unTrackedDeviceIndex_Hmd];
221 if (hmdPose.bPoseIsValid && hmdPose.bDeviceIsConnected) { 221 if (hmdPose.bPoseIsValid && hmdPose.bDeviceIsConnected) {
222 const auto& transform = hmdPose.mDeviceToAbsoluteTracking; 222 const auto& transform = hmdPose.mDeviceToAbsoluteTracking;
223 const auto& m = transform.m; 223 const auto& m = transform.m;
224 float w = sqrt(1 + m[0][0] + m[1][1] + m[2][2]); 224 float w = sqrt(1 + m[0][0] + m[1][1] + m[2][2]);
225 pose->orientation.value()[0] = (m[2][1] - m[1][2]) / (4 * w); 225 pose->orientation.value()[0] = (m[2][1] - m[1][2]) / (4 * w);
226 pose->orientation.value()[1] = (m[0][2] - m[2][0]) / (4 * w); 226 pose->orientation.value()[1] = (m[0][2] - m[2][0]) / (4 * w);
227 pose->orientation.value()[2] = (m[1][0] - m[0][1]) / (4 * w); 227 pose->orientation.value()[2] = (m[1][0] - m[0][1]) / (4 * w);
228 pose->orientation.value()[3] = w; 228 pose->orientation.value()[3] = w;
229 229
(...skipping 19 matching lines...) Expand all
249 base::TimeDelta time = base::TimeDelta::FromSecondsD(2.0); 249 base::TimeDelta time = base::TimeDelta::FromSecondsD(2.0);
250 250
251 device::mojom::VRPosePtr pose = getPose(); 251 device::mojom::VRPosePtr pose = getPose();
252 Sleep(11); // TODO (billorr): Use real vsync timing instead of a sleep (this 252 Sleep(11); // TODO (billorr): Use real vsync timing instead of a sleep (this
253 // sleep just throttles vsyncs so we don't fill message queues). 253 // sleep just throttles vsyncs so we don't fill message queues).
254 callback.Run(std::move(pose), time, frame, 254 callback.Run(std::move(pose), time, frame,
255 device::mojom::VRVSyncProvider::Status::SUCCESS); 255 device::mojom::VRVSyncProvider::Status::SUCCESS);
256 } 256 }
257 257
258 } // namespace device 258 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698