| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/android/vr_shell/vr_controller.h" | 5 #include "chrome/browser/android/vr_shell/vr_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Use orientation to rotate acceleration/gyro into seated space. | 112 // Use orientation to rotate acceleration/gyro into seated space. |
| 113 vr::Mat4f pose_mat; | 113 vr::Mat4f pose_mat; |
| 114 vr::QuatToMatrix(pad.orientation, &pose_mat); | 114 vr::QuatToMatrix(pad.orientation, &pose_mat); |
| 115 const gvr::Vec3f& accel = controller_state_->GetAccel(); | 115 const gvr::Vec3f& accel = controller_state_->GetAccel(); |
| 116 const gvr::Vec3f& gyro = controller_state_->GetGyro(); | 116 const gvr::Vec3f& gyro = controller_state_->GetGyro(); |
| 117 pad.accel = | 117 pad.accel = |
| 118 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(accel.x, accel.y, accel.z)); | 118 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(accel.x, accel.y, accel.z)); |
| 119 pad.gyro = | 119 pad.gyro = |
| 120 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(gyro.x, gyro.y, gyro.z)); | 120 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(gyro.x, gyro.y, gyro.z)); |
| 121 | 121 |
| 122 pad.is_touching = controller_state_->IsTouching(); | 122 pad.is_controller_touching = controller_state_->IsTouching(); |
| 123 pad.controller_button_pressed = | 123 pad.controller_button_pressed = |
| 124 controller_state_->GetButtonState(GVR_CONTROLLER_BUTTON_CLICK); | 124 controller_state_->GetButtonState(GVR_CONTROLLER_BUTTON_CLICK); |
| 125 pad.right_handed = handedness_ == GVR_CONTROLLER_RIGHT_HANDED; | 125 pad.right_handed = handedness_ == GVR_CONTROLLER_RIGHT_HANDED; |
| 126 | 126 |
| 127 return pad; | 127 return pad; |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool VrController::IsTouching() { | 130 bool VrController::IsTouching() { |
| 131 return controller_state_->IsTouching(); | 131 return controller_state_->IsTouching(); |
| 132 } | 132 } |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 const gfx::Vector2dF& velocity = ScaleVector2d(displacement, (1 / duration)); | 440 const gfx::Vector2dF& velocity = ScaleVector2d(displacement, (1 / duration)); |
| 441 | 441 |
| 442 float weight = duration / (kRC + duration); | 442 float weight = duration / (kRC + duration); |
| 443 | 443 |
| 444 overall_velocity_ = ScaleVector2d(overall_velocity_, (1 - weight)) + | 444 overall_velocity_ = ScaleVector2d(overall_velocity_, (1 - weight)) + |
| 445 ScaleVector2d(velocity, weight); | 445 ScaleVector2d(velocity, weight); |
| 446 } | 446 } |
| 447 | 447 |
| 448 } // namespace vr_shell | 448 } // namespace vr_shell |
| OLD | NEW |