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

Unified Diff: chrome/browser/android/vr_shell/vr_controller.cc

Issue 2770353002: WebVR: add angular velocity estimate to pose (Closed)
Patch Set: Move angular velocity calculation to helper function 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_controller.cc
diff --git a/chrome/browser/android/vr_shell/vr_controller.cc b/chrome/browser/android/vr_shell/vr_controller.cc
index f55ac5c997f3e9e2104b62aeef2a9e0a6bc68857..99447577d8e143335ab6bb27f09df2e8067ee852 100644
--- a/chrome/browser/android/vr_shell/vr_controller.cc
+++ b/chrome/browser/android/vr_shell/vr_controller.cc
@@ -110,8 +110,12 @@ device::GvrGamepadData VrController::GetGamepadData() {
pad.timestamp = controller_state_->GetLastOrientationTimestamp();
pad.touch_pos = controller_state_->GetTouchPos();
pad.orientation = controller_state_->GetOrientation();
- pad.accel = controller_state_->GetAccel();
- pad.gyro = controller_state_->GetGyro();
+
+ // Use orientation to rotate acceleration/gyro into seated space.
+ gvr::Mat4f pose_mat = QuatToMatrix(pad.orientation);
+ pad.accel = MatrixVectorMul(pose_mat, controller_state_->GetAccel());
+ pad.gyro = MatrixVectorMul(pose_mat, controller_state_->GetGyro());
+
pad.is_touching = controller_state_->IsTouching();
pad.controller_button_pressed =
controller_state_->GetButtonState(GVR_CONTROLLER_BUTTON_CLICK);
@@ -234,9 +238,10 @@ void VrController::Initialize(gvr_context* gvr_context) {
int32_t options = gvr::ControllerApi::DefaultOptions();
- // Enable non-default options - WebVR needs gyro, and since VrShell
- // implements GvrGamepadDataProvider we need this always.
+ // Enable non-default options - WebVR needs gyro and linear acceleration, and
+ // since VrShell implements GvrGamepadDataProvider we need this always.
options |= GVR_CONTROLLER_ENABLE_GYRO;
+ options |= GVR_CONTROLLER_ENABLE_ACCEL;
CHECK(controller_api_->Init(options, gvr_context));
« no previous file with comments | « chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc ('k') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698