Implement poses functions with "seconds from now" - #245
Conversation
f5063f4 to
549cd76
Compare
|
I could test GetPoseActionDataRelativeToNow in The Lab, which doesn't make any visible change. |
8caf88e to
2a30a5c
Compare
Supreeeme
left a comment
There was a problem hiding this comment.
This could use a test if you're up to writing one, if not I'll write it myself.
| session_data: &SessionData, | ||
| origin: vr::ETrackingUniverseOrigin, | ||
| ) -> Option<vr::TrackedDevicePose_t> { | ||
| let nanos = xr_time.as_nanos(); |
There was a problem hiding this comment.
Why not have the pose cache be Mutex<HashMap<xr::Time, TrackedDevicePose>>?
There was a problem hiding this comment.
It complained that xr::Time was not hashable:
Compiling xrizer v0.3.0 (/home/xytovl/projects/xrizer)
error[E0599]: the method `get` exists for struct `std::sync::MutexGuard<'_, HashMap<openxr::Time, TrackedDevicePose_t>>`, but its trait bounds were not satisfied
--> src/input/devices.rs:91:40
|
91 | if let Some(pose) = pose_cache.get(xr_time) {
| ^^^ method cannot be called due to unsatisfied trait bounds
|
::: /home/xytovl/.cargo/git/checkouts/openxrs-419b52284129469d/d0afdd3/sys/src/lib.rs:46:1
|
46 | pub struct Time(i64);
| --------------- doesn't satisfy `openxr::Time: Hash`
|
= note: the following trait bounds were not satisfied:
`openxr::Time: Hash`
There was a problem hiding this comment.
Ah. In this case I'd prefer if a type like this was defined:
#[derive(PartialEq, Eq, derive_more::From, Copy, Clone)]
struct Time(xr::Time);
impl Hash for Time {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.as_nanos().hash(state);
}
}Then you should be able to use it like:
pose_cache.get(&Time(xr_time))
pose_cache.insert(Time(xr_time))
// etc2a30a5c to
ad68355
Compare
What would you test? The cache mechanism, relative time, fallback if openxr now is not available? |
Relative time. Check that the poses returned from GetPoseActionDataRelativeToNow( and GetPoseActionDataForNextFrame actually differ, and that it returns the right pose basically. The way xrizer handles tests is primarily unit testing each interface with a mocked OpenXR runtime, this fake runtime lives in the |
|
Sorry I keep accidentally closing it lol |
OpenXR doesn't natively have a concept of "now", but has extensions to convert OS time to XrTime so that we can implement relative time ourselves.
GetPoseActionDataRelativeToNow is used for instance in The Lab, the change does however not fix the hand movement which is still not smooth.