Skip to content

Commit

Permalink
feat(common): ✨ Add Pose * DeviceMotion operator (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp authored Dec 15, 2024
1 parent f79f8ca commit 84620f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 12 additions & 0 deletions alvr/common/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ pub struct DeviceMotion {
pub linear_velocity: Vec3,
pub angular_velocity: Vec3,
}

impl Mul<DeviceMotion> for Pose {
type Output = DeviceMotion;

fn mul(self, rhs: DeviceMotion) -> DeviceMotion {
DeviceMotion {
pose: self * rhs.pose,
linear_velocity: self.orientation * rhs.linear_velocity,
angular_velocity: self.orientation * rhs.angular_velocity,
}
}
}
6 changes: 1 addition & 5 deletions alvr/server_core/src/tracking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ impl TrackingManager {
}

pub fn recenter_motion(&self, motion: DeviceMotion) -> DeviceMotion {
DeviceMotion {
pose: self.recenter_pose(motion.pose),
linear_velocity: self.inverse_recentering_origin.orientation * motion.linear_velocity,
angular_velocity: self.inverse_recentering_origin.orientation * motion.angular_velocity,
}
self.inverse_recentering_origin * motion
}

// Performs all kinds of tracking transformations, driven by settings.
Expand Down

0 comments on commit 84620f4

Please sign in to comment.