Skip to content
Permalink
Browse files

Rename incorrectly-named get_pose methods

  • Loading branch information...
Manishearth committed Apr 4, 2019
1 parent f1b82f8 commit d2e2b8da4da132390225ffc85adb8a33a1b36c13
@@ -54,26 +54,35 @@ impl XRReferenceSpaceMethods for XRReferenceSpace {
}

impl XRReferenceSpace {
/// Gets viewer pose represented by this space
/// Gets pose of the viewer with respect to this space
pub fn get_viewer_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
let pose = self.get_pose(base_pose);
let pose = self.get_unoffset_viewer_pose(base_pose);

// This may change, see https://github.com/immersive-web/webxr/issues/567
let offset = self.transform.get().transform();
let inverse = offset.inverse();
inverse.pre_mul(&pose)
}

/// Gets pose represented by this space
/// Gets pose of the viewer with respect to this space
///
/// Does not apply originOffset, use get_viewer_pose instead if you need it
pub fn get_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
pub fn get_unoffset_viewer_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
if let Some(stationary) = self.downcast::<XRStationaryReferenceSpace>() {
stationary.get_pose(base_pose)
stationary.get_unoffset_viewer_pose(base_pose)
} else {
// non-subclassed XRReferenceSpaces exist, obtained via the "identity"
// type. The pose does not depend on the base pose.
RigidTransform3D::identity()
}
}

/// Gets pose represented by this space
///
/// 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, _: &WebVRFrameData) -> RigidTransform3D<f64> {
unimplemented!()
}
}
@@ -39,7 +39,7 @@ impl XRSpace {
}

impl XRSpace {
/// Gets viewer pose represented by this space
/// Gets pose of the viewer with respect to this space
#[allow(unused)]
pub fn get_viewer_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
if let Some(reference) = self.downcast::<XRReferenceSpace>() {
@@ -51,7 +51,9 @@ impl XRSpace {

/// Gets pose represented by this space
///
/// Does not apply originOffset, use get_viewer_pose instead if you need it
/// 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
#[allow(unused)]
pub fn get_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
if let Some(reference) = self.downcast::<XRReferenceSpace>() {
@@ -50,10 +50,10 @@ impl XRStationaryReferenceSpace {
}

impl XRStationaryReferenceSpace {
/// Gets pose represented by this space
/// Gets pose of the viewer with respect to this space
///
/// Does not apply originOffset, use get_viewer_pose instead
pub fn get_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
/// Does not apply originOffset, use get_viewer_pose on XRReferenceSpace instead
pub fn get_unoffset_viewer_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> {
// XXXManishearth add floor-level transform for floor-level and disable position in position-disabled
let pos = base_pose.pose.position.unwrap_or([0., 0., 0.]);
let translation = Vector3D::new(pos[0] as f64, pos[1] as f64, pos[2] as f64);

0 comments on commit d2e2b8d

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