pub struct OpenXrPanelGrabState {
pub local_grab_point_m: Vec3,
pub last_valid_head_pos: Option<Vec3>,
pub last_valid_rotation: Quaternionf,
pub depth_axis: Option<Vec3>,
pub last_ray_origin: Option<Vec3>,
}Expand description
Retained state that keeps a grabbed panel point stable while it reorients.
World-space vectors use metres. Optional head and ray fields are None until
the corresponding valid pose has been observed.
§Examples
use ailloli_ui_openxr::openxr_runtime::OpenXrPanelGrabState;
use ailloli_ui_openxr::math::Vec3;
let grab = OpenXrPanelGrabState::new(Vec3::default(), openxr::Posef::IDENTITY.orientation);
assert!(grab.depth_axis.is_none());Fields§
§local_grab_point_m: Vec3Grabbed point in panel-local metres.
last_valid_head_pos: Option<Vec3>Most recently observed valid HMD position in world metres.
last_valid_rotation: QuaternionfMost recently applied valid panel orientation.
depth_axis: Option<Vec3>Normalized initial pointer direction used for depth translation.
last_ray_origin: Option<Vec3>Last pointer origin paired with depth_axis.
Implementations§
Source§impl OpenXrPanelGrabState
impl OpenXrPanelGrabState
Sourcepub fn new(local_grab_point_m: Vec3, initial_rotation: Quaternionf) -> Self
pub fn new(local_grab_point_m: Vec3, initial_rotation: Quaternionf) -> Self
Creates a grab state with no head pose or pointer-depth history.
§Examples
use ailloli_ui_openxr::openxr_runtime::OpenXrPanelGrabState;
use ailloli_ui_openxr::math::Vec3;
let state = OpenXrPanelGrabState::new(Vec3::new(0.1, 0.2, 0.0), openxr::Posef::IDENTITY.orientation);
assert_eq!(state.local_grab_point_m.x, 0.1);Sourcepub fn with_pointer_depth(self, ray_origin: Vec3, ray_direction: Vec3) -> Self
pub fn with_pointer_depth(self, ray_origin: Vec3, ray_direction: Vec3) -> Self
Initializes pointer-depth tracking and returns the updated state.
A near-zero direction leaves both depth fields None.
§Examples
use ailloli_ui_openxr::openxr_runtime::OpenXrPanelGrabState;
use ailloli_ui_openxr::math::Vec3;
let state = OpenXrPanelGrabState::new(Vec3::default(), openxr::Posef::IDENTITY.orientation).with_pointer_depth(Vec3::default(), Vec3::new(0.0, 0.0, -2.0));
assert_eq!(state.depth_axis, Some(Vec3::new(0.0, 0.0, -1.0)));Sourcepub fn set_pointer_depth(&mut self, ray_origin: Vec3, ray_direction: Vec3)
pub fn set_pointer_depth(&mut self, ray_origin: Vec3, ray_direction: Vec3)
Replaces the normalized depth axis and its initial ray origin.
A direction of length at most 1e-6 clears both values.
§Examples
use ailloli_ui_openxr::openxr_runtime::OpenXrPanelGrabState;
use ailloli_ui_openxr::math::Vec3;
let mut state = OpenXrPanelGrabState::new(Vec3::default(), openxr::Posef::IDENTITY.orientation);
state.set_pointer_depth(Vec3::new(1.0, 2.0, 3.0), Vec3::default());
assert!(state.last_ray_origin.is_none());Trait Implementations§
Source§impl Clone for OpenXrPanelGrabState
impl Clone for OpenXrPanelGrabState
Source§fn clone(&self) -> OpenXrPanelGrabState
fn clone(&self) -> OpenXrPanelGrabState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenXrPanelGrabState
impl Debug for OpenXrPanelGrabState
impl Copy for OpenXrPanelGrabState
Auto Trait Implementations§
impl Freeze for OpenXrPanelGrabState
impl RefUnwindSafe for OpenXrPanelGrabState
impl Send for OpenXrPanelGrabState
impl Sync for OpenXrPanelGrabState
impl Unpin for OpenXrPanelGrabState
impl UnwindSafe for OpenXrPanelGrabState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more