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

Unified Diff: chrome/browser/android/vr_shell/ui_elements.h

Issue 2730883003: Remove unnecessary UI element math. (Closed)
Patch Set: Add comments to non-obvious methods. Created 3 years, 9 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 | chrome/browser/android/vr_shell/ui_elements.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/ui_elements.h
diff --git a/chrome/browser/android/vr_shell/ui_elements.h b/chrome/browser/android/vr_shell/ui_elements.h
index ec6d78a0f93bcecc35efc457764660aca2e877ab..e0cf26af47f09ae17f67fe72494bd5d23bff4f1e 100644
--- a/chrome/browser/android/vr_shell/ui_elements.h
+++ b/chrome/browser/android/vr_shell/ui_elements.h
@@ -44,8 +44,8 @@ enum Fill {
CONTENT = 4,
};
-struct ReversibleTransform {
- ReversibleTransform();
+struct Transform {
+ Transform();
void MakeIdentity();
void Rotate(gvr::Quatf quat);
@@ -54,23 +54,32 @@ struct ReversibleTransform {
void Scale(float sx, float sy, float sz);
gvr::Mat4f to_world;
- gvr::Mat4f from_world;
-
- // This object-to-world orientation quaternion is technically
- // redundant, but it's easy to track it here for use as needed.
- // TODO(klausw): use this instead of MatrixVectorRotation()?
- // Would need quat * vector implementation.
- gvr::Quatf orientation = {0.0f, 0.0f, 0.0f, 1.0f};
};
-struct WorldObject {
- ReversibleTransform transform;
-};
+class WorldRectangle {
+ public:
+ const gvr::Mat4f& TransformMatrix() const;
+ void SetTransform(const Transform& transform);
-struct WorldRectangle : public WorldObject {
gvr::Vec3f GetCenter() const;
gvr::Vec3f GetNormal() const;
- float GetRayDistance(gvr::Vec3f rayOrigin, gvr::Vec3f rayVector) const;
+
+ // Computes the distance from |ray_origin| to this rectangles's plane, along
+ // |ray_vector|. Returns true and populates |distance| if the calculation is
+ // possible, and false if the ray is parallel to the plane.
+ bool GetRayDistance(const gvr::Vec3f& ray_origin,
+ const gvr::Vec3f& ray_vector,
+ float* distance) const;
+
+ // Projects a 3D world point onto the X and Y axes of the transformed
+ // rectangle, returning 2D coordinates relative to the un-transformed unit
+ // rectangle. This allows beam intersection points to be mapped to sprite
+ // pixel coordinates. Points that fall onto the rectangle will generate X and
+ // Y values on the interval [-0.5, 0.5].
+ gvr::Vec2f GetUnitRectangleCoordinates(const gvr::Vec3f& world_point);
+
+ private:
+ Transform transform_;
};
struct ContentRectangle : public WorldRectangle {
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/ui_elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698