mirror of
https://github.com/mii443/rust-openvr.git
synced 2025-08-22 16:25:36 +00:00
Simplify TrackedDevicePoses
This commit is contained in:
@ -54,8 +54,8 @@ impl<'a> Compositor<'a> {
|
|||||||
pub fn wait_get_poses(&self) -> Result<WaitPoses, CompositorError> {
|
pub fn wait_get_poses(&self) -> Result<WaitPoses, CompositorError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut result: WaitPoses = mem::uninitialized();
|
let mut result: WaitPoses = mem::uninitialized();
|
||||||
let e = (self.0.WaitGetPoses.unwrap())(result.render.data.as_mut().as_mut_ptr() as *mut _, result.render.data.len() as u32,
|
let e = (self.0.WaitGetPoses.unwrap())(result.render.as_mut().as_mut_ptr() as *mut _, result.render.len() as u32,
|
||||||
result.game.data.as_mut().as_mut_ptr() as *mut _, result.game.data.len() as u32);
|
result.game.as_mut().as_mut_ptr() as *mut _, result.game.len() as u32);
|
||||||
if e == sys::EVRCompositorError_EVRCompositorError_VRCompositorError_None {
|
if e == sys::EVRCompositorError_EVRCompositorError_VRCompositorError_None {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
extern crate openvr_sys;
|
extern crate openvr_sys;
|
||||||
|
|
||||||
use std::sync::atomic::{Ordering, AtomicBool, ATOMIC_BOOL_INIT};
|
use std::sync::atomic::{Ordering, AtomicBool, ATOMIC_BOOL_INIT};
|
||||||
use std::{fmt, error, slice};
|
use std::{fmt, error};
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
use openvr_sys as sys;
|
use openvr_sys as sys;
|
||||||
|
@ -81,7 +81,7 @@ impl<'a> System<'a> {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let mut result: TrackedDevicePoses = mem::uninitialized();
|
let mut result: TrackedDevicePoses = mem::uninitialized();
|
||||||
(self.0.GetDeviceToAbsoluteTrackingPose.unwrap())(origin as sys::ETrackingUniverseOrigin, predicted_seconds_to_photons_from_now,
|
(self.0.GetDeviceToAbsoluteTrackingPose.unwrap())(origin as sys::ETrackingUniverseOrigin, predicted_seconds_to_photons_from_now,
|
||||||
result.data.as_mut().as_mut_ptr() as *mut _, result.data.len() as u32);
|
result.as_mut().as_mut_ptr() as *mut _, result.len() as u32);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,20 +65,4 @@ pub enum TrackedControllerRole {
|
|||||||
RightHand = sys::ETrackedControllerRole_ETrackedControllerRole_TrackedControllerRole_RightHand as isize,
|
RightHand = sys::ETrackedControllerRole_ETrackedControllerRole_TrackedControllerRole_RightHand as isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
pub type TrackedDevicePoses = [TrackedDevicePose; sys::k_unMaxTrackedDeviceCount as usize];
|
||||||
pub struct TrackedDevicePoses {
|
|
||||||
data: [TrackedDevicePose; sys::k_unMaxTrackedDeviceCount as usize]
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TrackedDevicePoses {
|
|
||||||
pub fn iter(&self) -> slice::Iter<TrackedDevicePose> { self.data.iter() }
|
|
||||||
pub fn len(&self) -> usize { self.data.len() }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ::std::ops::Index<TrackedDeviceIndex> for TrackedDevicePoses {
|
|
||||||
type Output = TrackedDevicePose;
|
|
||||||
|
|
||||||
fn index(&self, index: TrackedDeviceIndex) -> &TrackedDevicePose {
|
|
||||||
&self.data[index as usize]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user