Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update XR code to use rigid transforms and new pose/transform stuff from the spec #23159

Merged
merged 13 commits into from
Apr 4, 2019

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Apr 3, 2019

This updates our XR code to use euclid's new RigidTransform3D type, which is more efficent and convenient to work with.

It additionally brings us up to speed with the spec:

Furthermore, it adds support for XRRigidTransform.matrix.

While fixing this I also noticed that our view matrix code was incorrect, we calculated view matrices as pose.to_column_major_array(), whereas it should be pose.inverse().to_row_major_array() (since Euclid uses row vectors, whenever the spec says it wants a column major array we should use .to_row_major_array() since all web specs implicitly use column vectors). For 3DOF devices poses are mostly rotations anyway, so the effective transpose behaved like an inversion, but was incorrect.

This PR gets rid of view.viewMatrix anyway, however I felt like I should mention this discrepancy, since otherwise the replacement of view.viewMatrix with view.transform.inverse.matrix doesn't make sense

r? @jdm


This change is Reviewable

@highfive
Copy link

highfive commented Apr 3, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/mod.rs, components/script/dom/webidls/XRView.webidl, components/script/Cargo.toml, components/script/dom/xrpose.rs, components/script/dom/xrreferencespace.rs and 12 more
  • @KiChjang: components/script/dom/mod.rs, components/script/dom/webidls/XRView.webidl, components/script/Cargo.toml, components/script/dom/xrpose.rs, components/script/dom/xrreferencespace.rs and 12 more

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 3, 2019
@highfive
Copy link

highfive commented Apr 3, 2019

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify script code, but no tests are modified. Please consider adding a test!

@Manishearth
Copy link
Member Author

Actually, probably should be r? @asajeffrey since he reviewed #23055

@highfive highfive assigned asajeffrey and unassigned jdm Apr 3, 2019
@Manishearth
Copy link
Member Author

There are still some changes left out of this PR which I may add later: namely, XRStationaryReferenceSpace::get_pose is a lie, it should be ::get_viewer_pose(). I was not interpreting the nature of reference spaces correctly, however my misinterpretation only affects the observed behavior of getPose(), which isn't implemented yet.

Nell mentioned that she had some feedback to give on immersive-web/webxr#565, so I'm going to hold off on making those changes till I know the real mental model involved.

@asajeffrey
Copy link
Member

LGTM. You might want to squash before merging.

@Manishearth
Copy link
Member Author

The commits are all self-contained, incremental, and building, and I prefer to have more commits whenever possible.

@bors-servo r=asajeffrey

@bors-servo
Copy link
Contributor

📌 Commit e8d172a has been approved by asajeffrey

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 4, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit e8d172a with merge 6e797f6...

bors-servo pushed a commit that referenced this pull request Apr 4, 2019
Update XR code to use rigid transforms and new pose/transform stuff from the spec

This updates our XR code to use euclid's new [RigidTransform3D type](servo/euclid#328), which is more efficent and convenient to work with.

It additionally brings us up to speed with the spec:

 - `XRViewerPose` was made a subclass of `XRPose` (immersive-web/webxr#496)
 - `XRView.viewMatrix` was removed in favor of `XRRigidTransform.inverse.matrix` (immersive-web/webxr#531)
 - `XRRigidTransform.inverse` is an attribute (immersive-web/webxr#560)
 - `XRRigidTransform` now validates positions in its constructor (immersive-web/webxr#568)

Furthermore, it adds support for `XRRigidTransform.matrix`.

While fixing this I also noticed that our view matrix code was incorrect, we calculated view matrices as `pose.to_column_major_array()`, whereas it *should* be `pose.inverse().to_row_major_array()` (since Euclid uses row vectors, whenever the spec says it wants a column major array we should use `.to_row_major_array()` since all web specs implicitly use column vectors). For 3DOF devices poses are mostly rotations anyway, so the effective transpose behaved _like_ an inversion, but was incorrect.

This PR gets rid of `view.viewMatrix` anyway, however I felt like I should mention this discrepancy, since otherwise the replacement of `view.viewMatrix` with `view.transform.inverse.matrix` doesn't make sense

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23159)
<!-- Reviewable:end -->
@Manishearth
Copy link
Member Author

(This PR is also like ... five changes at once)

@bors-servo
Copy link
Contributor

💔 Test failed - mac-rel-css1

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Apr 4, 2019
@Manishearth
Copy link
Member Author

@bors-servo retry

weird timeout in urlsearchparams-getall

@bors-servo
Copy link
Contributor

⚡ Previous build results for android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster are reusable. Rebuilding only mac-rel-css1...

@bors-servo
Copy link
Contributor

💔 Test failed - mac-rel-css1

@Manishearth
Copy link
Member Author

Huh, it's a different URLSearchParams test.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Apr 4, 2019
@Manishearth
Copy link
Member Author

@bors-servo try retry r-

@bors-servo
Copy link
Contributor

⌛ Trying commit e055884 with merge 21defb9...

bors-servo pushed a commit that referenced this pull request Apr 4, 2019
Update XR code to use rigid transforms and new pose/transform stuff from the spec

This updates our XR code to use euclid's new [RigidTransform3D type](servo/euclid#328), which is more efficent and convenient to work with.

It additionally brings us up to speed with the spec:

 - `XRViewerPose` was made a subclass of `XRPose` (immersive-web/webxr#496)
 - `XRView.viewMatrix` was removed in favor of `XRRigidTransform.inverse.matrix` (immersive-web/webxr#531)
 - `XRRigidTransform.inverse` is an attribute (immersive-web/webxr#560)
 - `XRRigidTransform` now validates positions in its constructor (immersive-web/webxr#568)

Furthermore, it adds support for `XRRigidTransform.matrix`.

While fixing this I also noticed that our view matrix code was incorrect, we calculated view matrices as `pose.to_column_major_array()`, whereas it *should* be `pose.inverse().to_row_major_array()` (since Euclid uses row vectors, whenever the spec says it wants a column major array we should use `.to_row_major_array()` since all web specs implicitly use column vectors). For 3DOF devices poses are mostly rotations anyway, so the effective transpose behaved _like_ an inversion, but was incorrect.

This PR gets rid of `view.viewMatrix` anyway, however I felt like I should mention this discrepancy, since otherwise the replacement of `view.viewMatrix` with `view.transform.inverse.matrix` doesn't make sense

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23159)
<!-- Reviewable:end -->
@Manishearth
Copy link
Member Author

I suspect that intermittent comes from one of the WPT updates but it's not clear why cc @jdm

It could also be due to the euclid bump but the relevant test isn't using euclid. A possibility is that a test running in parallel is using up all the cpu and causing timeouts elsewhere.

@bors-servo
Copy link
Contributor

@jdm
Copy link
Member

jdm commented Apr 4, 2019

@bors-servo r=asajeffrey

@bors-servo
Copy link
Contributor

📌 Commit e055884 has been approved by asajeffrey

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 4, 2019
bors-servo pushed a commit that referenced this pull request Apr 4, 2019
Update XR code to use rigid transforms and new pose/transform stuff from the spec

This updates our XR code to use euclid's new [RigidTransform3D type](servo/euclid#328), which is more efficent and convenient to work with.

It additionally brings us up to speed with the spec:

 - `XRViewerPose` was made a subclass of `XRPose` (immersive-web/webxr#496)
 - `XRView.viewMatrix` was removed in favor of `XRRigidTransform.inverse.matrix` (immersive-web/webxr#531)
 - `XRRigidTransform.inverse` is an attribute (immersive-web/webxr#560)
 - `XRRigidTransform` now validates positions in its constructor (immersive-web/webxr#568)

Furthermore, it adds support for `XRRigidTransform.matrix`.

While fixing this I also noticed that our view matrix code was incorrect, we calculated view matrices as `pose.to_column_major_array()`, whereas it *should* be `pose.inverse().to_row_major_array()` (since Euclid uses row vectors, whenever the spec says it wants a column major array we should use `.to_row_major_array()` since all web specs implicitly use column vectors). For 3DOF devices poses are mostly rotations anyway, so the effective transpose behaved _like_ an inversion, but was incorrect.

This PR gets rid of `view.viewMatrix` anyway, however I felt like I should mention this discrepancy, since otherwise the replacement of `view.viewMatrix` with `view.transform.inverse.matrix` doesn't make sense

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23159)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

⌛ Testing commit e055884 with merge 709cfeb...

@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel-css

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Apr 4, 2019
@bors-servo
Copy link
Contributor

💣 Failed to start rebuilding: Unknown error

@bors-servo
Copy link
Contributor

⌛ Testing commit e055884 with merge f1b82f8...

bors-servo pushed a commit that referenced this pull request Apr 4, 2019
Update XR code to use rigid transforms and new pose/transform stuff from the spec

This updates our XR code to use euclid's new [RigidTransform3D type](servo/euclid#328), which is more efficent and convenient to work with.

It additionally brings us up to speed with the spec:

 - `XRViewerPose` was made a subclass of `XRPose` (immersive-web/webxr#496)
 - `XRView.viewMatrix` was removed in favor of `XRRigidTransform.inverse.matrix` (immersive-web/webxr#531)
 - `XRRigidTransform.inverse` is an attribute (immersive-web/webxr#560)
 - `XRRigidTransform` now validates positions in its constructor (immersive-web/webxr#568)

Furthermore, it adds support for `XRRigidTransform.matrix`.

While fixing this I also noticed that our view matrix code was incorrect, we calculated view matrices as `pose.to_column_major_array()`, whereas it *should* be `pose.inverse().to_row_major_array()` (since Euclid uses row vectors, whenever the spec says it wants a column major array we should use `.to_row_major_array()` since all web specs implicitly use column vectors). For 3DOF devices poses are mostly rotations anyway, so the effective transpose behaved _like_ an inversion, but was incorrect.

This PR gets rid of `view.viewMatrix` anyway, however I felt like I should mention this discrepancy, since otherwise the replacement of `view.viewMatrix` with `view.transform.inverse.matrix` doesn't make sense

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23159)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Apr 4, 2019
@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Apr 4, 2019
@bors-servo
Copy link
Contributor

⚡ Previous build results for android-mac, arm32, arm64, linux-rel-css, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster are reusable. Rebuilding only linux-rel-wpt...

@bors-servo
Copy link
Contributor

☀️ Test successful - android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster
Approved by: asajeffrey
Pushing f1b82f8 to master...

@bors-servo bors-servo merged commit e055884 into servo:master Apr 4, 2019
@Manishearth Manishearth deleted the rigid-transforms branch May 7, 2019 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-tests-failed The changes caused existing tests to fail.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants