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

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

Issue 2392333003: Incorporate 15 degree laser beam angle on pointer. (Closed)
Patch Set: Tweaks Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index b8e905c54b031b67f5dfcf52816416821b05361c..b0b6b26c9ceefdae79281ec182dc4b45ff3cabe5 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -49,11 +49,8 @@ static constexpr float kReticleHeight = 0.025f;
static constexpr float kLaserWidth = 0.01f;
-// The neutral direction is fixed in world space, this is the
-// reference angle pointing forward towards the horizon when the
-// controller orientation is reset. This should match the yaw angle
-// where the main screen is placed.
-static constexpr gvr::Vec3f kNeutralPose = {0.0f, 0.0f, -1.0f};
+// Angle the beam down from the controller axis, for wrist comfort.
mthiesse 2016/10/05 23:29:10 nit: s/Angle/Angle (radians)/ ?
cjgrant 2016/10/06 15:07:51 Done.
+static constexpr float kLaserAngle = 0.26f;
mthiesse 2016/10/05 23:29:10 Daydream calls this kErgoAngleOffset, we should pr
cjgrant 2016/10/06 15:07:51 Done.
static constexpr gvr::Vec3f kOrigin = {0.0f, 0.0f, 0.0f};
@@ -239,16 +236,19 @@ void VrShell::UpdateController(const gvr::Vec3f& forward_vector) {
}
WebInputEvent::Type original_type = gesture->type;
+ gvr::Vec3f beam;
mthiesse 2016/10/05 23:29:10 'beam' here is slightly confusing. Maybe ergo_neut
cjgrant 2016/10/06 15:07:51 Done.
if (!controller_->IsConnected()) {
// No controller detected, set up a gaze cursor that tracks the
// forward direction.
+ beam = {0.0f, 0.0f, -1.0f};
controller_quat_ = GetRotationFromZAxis(forward_vector);
} else {
+ beam = {0.0f, -sin(kLaserAngle), -cos(kLaserAngle)};
controller_quat_ = controller_->Orientation();
}
gvr::Mat4f mat = QuatToMatrix(controller_quat_);
- gvr::Vec3f forward = MatrixVectorMul(mat, kNeutralPose);
+ gvr::Vec3f forward = MatrixVectorMul(mat, beam);
gvr::Vec3f origin = kHandPosition;
target_element_ = nullptr;
@@ -523,14 +523,31 @@ void VrShell::DrawCursor(const gvr::Mat4f& render_matrix) {
auto m = QuatToMatrix(q);
mat = MatrixMul(m, mat);
- // Orient according to controller position.
- mat = MatrixMul(QuatToMatrix(controller_quat_), mat);
-
- // Move the beam origin to the hand.
- TranslateM(mat, mat, kHandPosition.x, kHandPosition.y, kHandPosition.z);
-
- transform = MatrixMul(render_matrix, mat);
- vr_shell_renderer_->GetLaserRenderer()->Draw(transform);
+ const gvr::Vec3f beam_direction = {
+ target_point_.x - kHandPosition.x,
+ target_point_.y - kHandPosition.y,
+ target_point_.z - kHandPosition.z
+ };
+ auto beam_quat = GetRotationFromZAxis(beam_direction);
+
+ // Render multiple faces to make the laser appear cylindrical.
+ const auto faces = 4;
mthiesse 2016/10/05 23:29:10 Prefer types for simple types? 'int' is even short
cjgrant 2016/10/06 15:07:51 Done.
+ for (int i = 0; i < faces; i++) {
+ // Rotate around Z.
+ float angle = M_PI * 2 * i / faces;
+ auto rot = QuatFromAxisAngle({0.0f, 0.0f, 1.0f}, angle);
mthiesse 2016/10/05 23:29:10 I would prefer types here for clarity, but I'd lis
cjgrant 2016/10/06 15:07:51 Done. No argument. :)
+ auto face_mat = MatrixMul(QuatToMatrix(rot), mat);
+
+ // Orient according to target direction.
+ face_mat = MatrixMul(QuatToMatrix(beam_quat), face_mat);
+
+ // Move the beam origin to the hand.
+ TranslateM(face_mat, face_mat, kHandPosition.x, kHandPosition.y,
+ kHandPosition.z);
+
+ transform = MatrixMul(render_matrix, face_mat);
+ vr_shell_renderer_->GetLaserRenderer()->Draw(transform);
+ }
}
void VrShell::DrawWebVr() {
« 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