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

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

Issue 2698623007: Change how the VR reticle distance is determined. (Closed)
Patch Set: Change background distance multplier to 1.414; move Reload UI button out of the floor. Created 3 years, 10 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_shell_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index ac346c52e29e121ccb1e576647dccee318823cfa..73afb7117c0ac2266959055deaf971b4f109f303 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -57,19 +57,10 @@ static constexpr gvr::Vec3f kOrigin = {0.0f, 0.0f, 0.0f};
// TODO(mthiesse): Handedness options.
static constexpr gvr::Vec3f kHandPosition = {0.2f, -0.5f, -0.2f};
-// If there is no content quad, and the reticle isn't hitting another element,
-// draw the reticle at this distance.
-static constexpr float kDefaultReticleDistance = 2.0f;
-
// Fraction of the distance to the object the cursor is drawn at to avoid
// rounding errors drawing the cursor behind the object.
static constexpr float kReticleOffset = 0.99f;
-// Limit the rendering distance of the reticle to the distance to a corner of
-// the content quad, times this value. This lets the rendering distance
-// adjust according to content quad placement.
-static constexpr float kReticleDistanceMultiplier = 1.5f;
-
// GVR buffer indices for use with viewport->SetSourceBufferIndex
// or frame.BindBuffer. We use one for world content (with reprojection)
// including main VrShell and WebVR content plus world-space UI.
@@ -471,37 +462,23 @@ void VrShellGl::UpdateController(const gvr::Vec3f& forward_vector) {
// in the field of view. This is physically correct, but hard to use. For
// usability, do the following instead:
//
- // - Project the controller laser onto an outer surface, which is the
- // closer of the desktop plane, or a distance-limiting sphere.
+ // - Project the controller laser onto a distance-limiting sphere.
// - Create a vector between the eyes and the outer surface point.
- // - If any UI elements intersect this vector, choose the closest to the eyes,
- // and place the reticle at the intersection point.
-
- // Find distance to a corner of the content quad, and limit the cursor
- // distance to a multiple of that distance. This lets us keep the reticle on
- // the content plane near the content window, and on the surface of a sphere
- // in other directions. Note that this approach uses distance from controller,
- // rather than eye, for simplicity. This will make the sphere slightly
- // off-center.
- float distance = kDefaultReticleDistance;
- ContentRectangle* content_plane = scene_->GetContentQuad();
- if (content_plane) {
- distance = content_plane->GetRayDistance(origin, forward);
- gvr::Vec3f corner = {0.5f, 0.5f, 0.0f};
- corner = MatrixVectorMul(content_plane->transform.to_world, corner);
- float max_distance = Distance(origin, corner) * kReticleDistanceMultiplier;
- if (distance > max_distance || distance <= 0.0f) {
- distance = max_distance;
- }
- }
-
+ // - If any UI elements intersect this vector, and is within the bounding
+ // sphere, choose the closest to the eyes, and place the reticle at the
+ // intersection point.
+
+ // Compute the distance from the eyes to the distance limiting sphere. Note
+ // that the sphere is centered at the controller, rather than the eye, for
+ // simplicity.
+ float distance = scene_->GetBackgroundDistance();
target_point_ = GetRayPoint(origin, forward, distance);
gvr::Vec3f eye_to_target = target_point_;
NormalizeVector(eye_to_target);
// Determine which UI element (if any) intersects the line between the eyes
// and the controller target position.
- float closest_element_distance = std::numeric_limits<float>::infinity();
+ float closest_element_distance = VectorLength(target_point_);
int pixel_x = 0;
int pixel_y = 0;
target_element_ = nullptr;
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_unittest.cc ('k') | chrome/browser/resources/vr_shell/vr_shell_ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698