This commit is contained in:
galister
2024-02-20 20:55:14 +01:00
parent d31b3ca6c0
commit e7b415ae4e
12 changed files with 34 additions and 45 deletions

View File

@@ -57,20 +57,20 @@ where
crate::overlays::screen::get_screens_x11(&app.session)?
};
let mut watch = create_watch::<T>(&app, &screens)?;
let mut watch = create_watch::<T>(app, &screens)?;
watch.state.want_visible = true;
overlays.insert(watch.state.id, watch);
let mut keyboard = create_keyboard(&app)?;
let mut keyboard = create_keyboard(app)?;
keyboard.state.show_hide = true;
keyboard.state.want_visible = false;
overlays.insert(keyboard.state.id, keyboard);
let mut show_screens = app.session.config.show_screens.clone();
if show_screens.is_empty() {
screens.first().and_then(|s| {
screens.first().map(|s| {
show_screens.push(s.state.name.clone());
Some(())
});
}
@@ -102,17 +102,17 @@ where
.iter()
.find(|(_, o)| *o.state.name == **name)
.map(|(id, _)| *id);
id.and_then(|id| self.overlays.remove(&id));
id.and_then(|id| self.overlays.remove(id));
}
};
}
pub fn get_by_id<'a>(&'a mut self, id: usize) -> Option<&'a OverlayData<T>> {
self.overlays.get(&id)
pub fn get_by_id(&mut self, id: usize) -> Option<&OverlayData<T>> {
self.overlays.get(id)
}
pub fn mut_by_id<'a>(&'a mut self, id: usize) -> Option<&'a mut OverlayData<T>> {
self.overlays.get_mut(&id)
pub fn mut_by_id(&mut self, id: usize) -> Option<&mut OverlayData<T>> {
self.overlays.get_mut(id)
}
pub fn get_by_name<'a>(&'a mut self, name: &str) -> Option<&'a OverlayData<T>> {
@@ -123,11 +123,11 @@ where
self.overlays.values_mut().find(|o| *o.state.name == *name)
}
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a OverlayData<T>> {
pub fn iter(&self) -> impl Iterator<Item = &'_ OverlayData<T>> {
self.overlays.values()
}
pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut OverlayData<T>> {
pub fn iter_mut(&mut self) -> impl Iterator<Item = &'_ mut OverlayData<T>> {
self.overlays.values_mut()
}

View File

@@ -128,15 +128,13 @@ impl OpenVrInputSource {
system: &mut SystemManager,
app: &mut AppState,
) {
let aas = ActiveActionSet {
0: ovr_overlay::sys::VRActiveActionSet_t {
let aas = ActiveActionSet(ovr_overlay::sys::VRActiveActionSet_t {
ulActionSet: self.set_hnd.0,
ulRestrictedToDevice: 0,
ulSecondaryActionSet: 0,
unPadding: 0,
nPriority: 0,
},
};
});
let _ = input.update_actions(&mut [aas]);
@@ -155,10 +153,10 @@ impl OpenVrInputSource {
0.005,
INPUT_ANY,
)
.and_then(|pose| {
.map(|pose| {
app_hand.pose = pose.0.pose.mDeviceToAbsoluteTracking.to_affine();
hand.has_pose = true;
Ok(())
});
app_hand.now.click = input
@@ -237,9 +235,9 @@ impl OpenVrInputSource {
_ => continue,
};
get_tracked_device(system, device, role).and_then(|device| {
get_tracked_device(system, device, role).map(|device| {
app.input_state.devices.push(device);
Some(())
});
}

View File

@@ -95,7 +95,7 @@ impl LinePool {
) {
let rotation = Affine3A::from_axis_angle(Vec3::X, -PI * 0.5);
from.translation = from.translation + from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
from.translation += from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
let mut transform = from * rotation * Affine3A::from_scale(Vec3::new(1., len / 0.002, 1.));
let to_hmd = hmd.translation - from.translation;
@@ -114,7 +114,7 @@ impl LinePool {
}
}
transform = transform * rotations[closest.0];
transform *= rotations[closest.0];
debug_assert!(color < self.colors.len());

View File

@@ -73,8 +73,8 @@ impl OpenXrInputSource {
Ok(Self {
action_set,
hands: [
OpenXrHand::new(&xr, left_source)?,
OpenXrHand::new(&xr, right_source)?,
OpenXrHand::new(xr, left_source)?,
OpenXrHand::new(xr, right_source)?,
],
})
}

View File

@@ -94,14 +94,14 @@ impl LinePool {
debug_assert!(color < self.colors.len());
let Some(line) = self.lines.get_mut(&id) else {
let Some(line) = self.lines.get_mut(id) else {
log::warn!("Line {} not found", id);
return;
};
let rotation = Affine3A::from_axis_angle(Vec3::X, PI * 1.5);
from.translation = from.translation + from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
from.translation += from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
let mut transform = from * rotation;
let to_hmd = hmd.translation - from.translation;
@@ -120,7 +120,7 @@ impl LinePool {
}
}
transform = transform * rotations[closest.0];
transform *= rotations[closest.0];
let posef = helpers::transform_to_posef(&transform);

View File

@@ -221,11 +221,8 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
.input_state
.pointers
.iter()
.any(|p| p.now.show_hide && !p.before.show_hide)
{
if show_hide_counter.click() {
overlays.show_hide(&mut app_state);
}
.any(|p| p.now.show_hide && !p.before.show_hide) && show_hide_counter.click() {
overlays.show_hide(&mut app_state);
}
watch_fade(&mut app_state, overlays.mut_by_id(watch_id).unwrap()); // want panic