Watch rotation + galister fixes (Keyboard mapping fix, OpenXR hand transform fix) (#4)
* Watch rotation + galister fixes (Keyboard mapping fix, OpenXR hand transform fix) * Use from_scale_rotation_translation
This commit is contained in:
@@ -353,7 +353,10 @@ fn quat_lerp(a: Quat, mut b: Quat, t: f32) -> Quat {
|
||||
|
||||
fn transform_to_posef(transform: &Affine3A) -> xr::Posef {
|
||||
let translation = transform.translation;
|
||||
let rotation = Quat::from_affine3(transform).normalize();
|
||||
let norm_mat3 = transform
|
||||
.matrix3
|
||||
.mul_scalar(1.0 / transform.matrix3.x_axis.length());
|
||||
let rotation = Quat::from_mat3a(&norm_mat3).normalize();
|
||||
|
||||
xr::Posef {
|
||||
orientation: xr::Quaternionf {
|
||||
|
||||
@@ -72,7 +72,7 @@ where
|
||||
fn default() -> Self {
|
||||
OverlayData {
|
||||
state: Default::default(),
|
||||
backend: Box::new(SplitOverlayBackend::default()),
|
||||
backend: Box::<SplitOverlayBackend>::default(),
|
||||
primary_pointer: None,
|
||||
data: Default::default(),
|
||||
}
|
||||
@@ -87,17 +87,22 @@ impl OverlayState {
|
||||
RelativeTo::Hand(idx) => Some(app.input_state.pointers[idx].pose),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn auto_movement(&mut self, app: &mut AppState) {
|
||||
if let Some(parent) = self.parent_transform(app) {
|
||||
self.transform = parent
|
||||
* Affine3A::from_scale_rotation_translation(
|
||||
Vec3::ONE * self.spawn_scale,
|
||||
self.spawn_rotation,
|
||||
self.spawn_rotation
|
||||
* Quat::from_rotation_x(f32::to_radians(-180.0))
|
||||
* Quat::from_rotation_z(f32::to_radians(180.0)),
|
||||
self.spawn_point.into(),
|
||||
);
|
||||
|
||||
self.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self, app: &mut AppState) {
|
||||
let translation = app.input_state.hmd.transform_point3a(self.spawn_point);
|
||||
self.transform = Affine3A::from_scale_rotation_translation(
|
||||
@@ -108,6 +113,7 @@ impl OverlayState {
|
||||
|
||||
self.realign(&app.input_state.hmd);
|
||||
}
|
||||
|
||||
pub fn realign(&mut self, hmd: &Affine3A) {
|
||||
let to_hmd = hmd.translation - self.transform.translation;
|
||||
let up_dir: Vec3A;
|
||||
|
||||
Reference in New Issue
Block a user