Skip to content
Permalink
Browse files

Make poses nullable

  • Loading branch information...
Manishearth committed Oct 3, 2019
1 parent 0780fb0 commit 1062249fd8457fb01a9d06649a8a1f8d355b1d6d
Showing with 14 additions and 5 deletions.
  1. +1 −0 components/script/dom/mod.rs
  2. +10 −2 components/script/dom/xrframe.rs
  3. +3 −3 components/script/dom/xrspace.rs
@@ -549,6 +549,7 @@ pub mod xmlserializer;
pub mod xr;
pub mod xrframe;
pub mod xrinputsource;
pub mod xrinputsourceevent;
pub mod xrpose;
pub mod xrreferencespace;
pub mod xrrenderstate;
@@ -93,8 +93,16 @@ impl XRFrameMethods for XRFrame {
if !self.active.get() {
return Err(Error::InvalidState);
}
let space = space.get_pose(&self.data);
let relative_to = relative_to.get_pose(&self.data);
let space = if let Some(space) = space.get_pose(&self.data) {
space
} else {
return Ok(None);
};
let relative_to = if let Some(r) = relative_to.get_pose(&self.data) {
r
} else {
return Ok(None);
};
let pose = relative_to.inverse().pre_transform(&space);
Ok(Some(XRPose::new(&self.global(), pose)))
}
@@ -57,9 +57,9 @@ impl XRSpace {
/// The reference origin used is common between all
/// get_pose calls for spaces from the same device, so this can be used to compare
/// with other spaces
pub fn get_pose(&self, base_pose: &Frame) -> ApiPose {
pub fn get_pose(&self, base_pose: &Frame) -> Option<ApiPose> {
if let Some(reference) = self.downcast::<XRReferenceSpace>() {
reference.get_pose(base_pose)
Some(reference.get_pose(base_pose))
} else if let Some(source) = self.input_source.get() {
// XXXManishearth we should be able to request frame information
// for inputs when necessary instead of always loading it
@@ -72,7 +72,7 @@ impl XRSpace {
.iter()
.find(|i| i.id == id)
.expect("no input found");
cast_transform(frame.target_ray_origin)
Some(cast_transform(frame.target_ray_origin))
} else {
unreachable!()
}

0 comments on commit 1062249

Please sign in to comment.
You can’t perform that action at this time.