pub struct OpenXrQuadPointerMapper;Expand description
Stateless world-ray mapper for one OpenXR quad layer.
§Examples
use ailloli_ui_core::Size;
use ailloli_ui_openxr::{OpenXrQuadLayerOptions, OpenXrQuadPointerMapper};
use ailloli_ui_openxr::math::Vec3;
let point = OpenXrQuadPointerMapper::ray_to_logical_point(Vec3::default(), Vec3::new(0.0, 0.0, -1.0), &OpenXrQuadLayerOptions::default(), Size::new(1024.0, 576.0));
assert_eq!(point.map(|p| (p.x, p.y)), Some((512.0, 288.0)));Implementations§
Source§impl OpenXrQuadPointerMapper
impl OpenXrQuadPointerMapper
Sourcepub fn ray_to_logical_point(
ray_origin: Vec3,
ray_direction: Vec3,
layer: &OpenXrQuadLayerOptions,
logical_size: Size,
) -> Option<Point>
pub fn ray_to_logical_point( ray_origin: Vec3, ray_direction: Vec3, layer: &OpenXrQuadLayerOptions, logical_size: Size, ) -> Option<Point>
Intersects a world ray and returns a top-left-origin logical point.
Returns None for parallel rays, hits behind the origin, or points beyond
the finite quad. Layer axes are derived from its quaternion and its physical
width/height are clamped to at least one millimetre before halving.
§Examples
use ailloli_ui_core::Size;
use ailloli_ui_openxr::{OpenXrQuadLayerOptions, OpenXrQuadPointerMapper};
use ailloli_ui_openxr::math::Vec3;
let point = OpenXrQuadPointerMapper::ray_to_logical_point(Vec3::default(), Vec3::new(0.0, 0.0, -1.0), &OpenXrQuadLayerOptions::default(), Size::new(100.0, 50.0)).unwrap();
assert_eq!((point.x, point.y), (50.0, 25.0));Sourcepub fn sample_from_ray(
source_id: u64,
ray_origin: Vec3,
ray_direction: Vec3,
trigger_pressed: bool,
layer: &OpenXrQuadLayerOptions,
logical_size: Size,
) -> OpenXrPointerSample
pub fn sample_from_ray( source_id: u64, ray_origin: Vec3, ray_direction: Vec3, trigger_pressed: bool, layer: &OpenXrQuadLayerOptions, logical_size: Size, ) -> OpenXrPointerSample
Creates a hit/miss pointer sample from a world ray.
Hit depth is deliberately None; this mapper preserves logical routing
only. Source ID and pressed state are preserved verbatim; scroll is zero.
§Examples
use ailloli_ui_core::Size;
use ailloli_ui_openxr::{OpenXrPointerHit, OpenXrQuadLayerOptions, OpenXrQuadPointerMapper};
use ailloli_ui_openxr::math::Vec3;
let sample = OpenXrQuadPointerMapper::sample_from_ray(7, Vec3::default(), Vec3::new(0.0, 0.0, -1.0), true, &OpenXrQuadLayerOptions::default(), Size::new(100.0, 50.0));
assert!(matches!(sample.hit, OpenXrPointerHit::Hit(_)) && sample.trigger_pressed);Sourcepub fn miss_sample(source_id: u64) -> OpenXrPointerSample
pub fn miss_sample(source_id: u64) -> OpenXrPointerSample
Creates an unpressed miss sample with zero scroll.
§Examples
use ailloli_ui_openxr::{OpenXrPointerHit, OpenXrQuadPointerMapper};
let sample = OpenXrQuadPointerMapper::miss_sample(9);
assert_eq!(sample.hit, OpenXrPointerHit::Miss);
assert!(!sample.trigger_pressed);Auto Trait Implementations§
impl Freeze for OpenXrQuadPointerMapper
impl RefUnwindSafe for OpenXrQuadPointerMapper
impl Send for OpenXrQuadPointerMapper
impl Sync for OpenXrQuadPointerMapper
impl Unpin for OpenXrQuadPointerMapper
impl UnwindSafe for OpenXrQuadPointerMapper
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
Mutably borrows from an owned value. Read more
§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<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>
Converts
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>
Converts
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