mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Make poses nullable
This commit is contained in:
parent
0780fb0693
commit
1062249fd8
3 changed files with 14 additions and 5 deletions
|
@ -549,6 +549,7 @@ pub mod xmlserializer;
|
||||||
pub mod xr;
|
pub mod xr;
|
||||||
pub mod xrframe;
|
pub mod xrframe;
|
||||||
pub mod xrinputsource;
|
pub mod xrinputsource;
|
||||||
|
pub mod xrinputsourceevent;
|
||||||
pub mod xrpose;
|
pub mod xrpose;
|
||||||
pub mod xrreferencespace;
|
pub mod xrreferencespace;
|
||||||
pub mod xrrenderstate;
|
pub mod xrrenderstate;
|
||||||
|
|
|
@ -93,8 +93,16 @@ impl XRFrameMethods for XRFrame {
|
||||||
if !self.active.get() {
|
if !self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState);
|
||||||
}
|
}
|
||||||
let space = space.get_pose(&self.data);
|
let space = if let Some(space) = space.get_pose(&self.data) {
|
||||||
let relative_to = relative_to.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);
|
let pose = relative_to.inverse().pre_transform(&space);
|
||||||
Ok(Some(XRPose::new(&self.global(), pose)))
|
Ok(Some(XRPose::new(&self.global(), pose)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,9 @@ impl XRSpace {
|
||||||
/// The reference origin used is common between all
|
/// The reference origin used is common between all
|
||||||
/// get_pose calls for spaces from the same device, so this can be used to compare
|
/// get_pose calls for spaces from the same device, so this can be used to compare
|
||||||
/// with other spaces
|
/// 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>() {
|
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() {
|
} else if let Some(source) = self.input_source.get() {
|
||||||
// XXXManishearth we should be able to request frame information
|
// XXXManishearth we should be able to request frame information
|
||||||
// for inputs when necessary instead of always loading it
|
// for inputs when necessary instead of always loading it
|
||||||
|
@ -72,7 +72,7 @@ impl XRSpace {
|
||||||
.iter()
|
.iter()
|
||||||
.find(|i| i.id == id)
|
.find(|i| i.id == id)
|
||||||
.expect("no input found");
|
.expect("no input found");
|
||||||
cast_transform(frame.target_ray_origin)
|
Some(cast_transform(frame.target_ray_origin))
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue