Function face_user_yaw_pitch_clamped

Source
pub fn face_user_yaw_pitch_clamped(
    panel_pos: Vec3,
    head_pos: Vec3,
    fallback: Quaternionf,
    pitch_min_rad: f32,
    pitch_max_rad: f32,
) -> (Quaternionf, bool, f32, bool)
Expand description

Computes viewer-facing yaw and pitch while keeping roll at zero.

Non-finite pitch bounds fall back to +/-45 degrees and reversed bounds are swapped. The returned tuple contains rotation, whether it was applied, applied pitch in degrees, and whether pitch was clamped. Degenerate horizontal direction returns the fallback with both booleans false.

ยงExamples

use ailloli_ui_openxr::{DEFAULT_PANEL_PITCH_MAX_RAD, DEFAULT_PANEL_PITCH_MIN_RAD};
use ailloli_ui_openxr::openxr_runtime::face_user_yaw_pitch_clamped;
use ailloli_ui_openxr::math::Vec3;
let (_, applied, pitch_deg, clamped) = face_user_yaw_pitch_clamped(Vec3::new(0.0, 0.0, -2.0), Vec3::new(0.0, 100.0, -1.9), openxr::Posef::IDENTITY.orientation, DEFAULT_PANEL_PITCH_MIN_RAD, DEFAULT_PANEL_PITCH_MAX_RAD);
assert!(applied && clamped);
assert!((pitch_deg - 45.0).abs() < 1e-4);