Skip to content

Commit

Permalink
fix controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Jan 11, 2025
1 parent f98ba44 commit 9d67a50
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions alvr/client_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ impl ClientCoreContext {
}
}

pub fn get_head_prediction_offset(&self) -> Duration {
dbg_client_core!("get_head_prediction_offset");
pub fn get_total_prediction_offset(&self) -> Duration {
dbg_client_core!("get_total_prediction_offset");

if let Some(stats) = &*self.connection_context.statistics_manager.lock() {
stats.average_total_pipeline_latency()
Expand Down
4 changes: 3 additions & 1 deletion alvr/client_openxr/src/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,10 @@ pub fn get_hand_data(
};

let hand_joints = if let Some(tracker) = &hand_source.skeleton_tracker {
let xr_now = crate::xr_runtime_now(xr_session.instance()).unwrap_or(xr_time);

if let Some(joint_locations) = reference_space
.locate_hand_joints(tracker, xr_time)
.locate_hand_joints(tracker, xr_now)
.ok()
.flatten()
{
Expand Down
25 changes: 17 additions & 8 deletions alvr/client_openxr/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ fn stream_input_loop(
// return poses in the "now" time, required by the ClientCore interface. This solution
// doesn't fix the issue completely, but most of the predicted time interval will be
// correct.
let head_time = if platform.is_pico() {
now + core_ctx.get_head_prediction_offset()
let target_time = if platform.is_pico() {
now + core_ctx.get_total_prediction_offset()
} else {
now
};
Expand All @@ -480,15 +480,15 @@ fn stream_input_loop(
platform,
stage_reference_space,
view_reference_space,
head_time,
target_time,
&last_view_params,
) else {
continue;
};

let head_motion = if platform.is_pico() {
// Predict back in time, matching the prediction that is done on later on
head_motion.predict(head_time, now)
head_motion.predict(target_time, now)
} else {
head_motion
};
Expand All @@ -502,23 +502,32 @@ fn stream_input_loop(

device_motions.push((*HEAD_ID, head_motion));

let (left_hand_motion, left_hand_skeleton) = crate::interaction::get_hand_data(
let (mut left_hand_motion, left_hand_skeleton) = crate::interaction::get_hand_data(
&xr_session,
stage_reference_space,
now,
target_time,
&int_ctx.hands_interaction[0],
&mut last_controller_poses[0],
&mut last_palm_poses[0],
);
let (right_hand_motion, right_hand_skeleton) = crate::interaction::get_hand_data(
let (mut right_hand_motion, right_hand_skeleton) = crate::interaction::get_hand_data(
&xr_session,
stage_reference_space,
now,
target_time,
&int_ctx.hands_interaction[1],
&mut last_controller_poses[1],
&mut last_palm_poses[1],
);

if platform.is_pico() {
if let Some(left_hand_motion) = &mut left_hand_motion {
*left_hand_motion = left_hand_motion.predict(target_time, now);
}
if let Some(right_hand_motion) = &mut right_hand_motion {
*right_hand_motion = right_hand_motion.predict(target_time, now);
}
}

// Note: When multimodal input is enabled, we are sure that when free hands are used
// (not holding controllers) the controller data is None.
if int_ctx.multimodal_hands_enabled || left_hand_skeleton.is_none() {
Expand Down

0 comments on commit 9d67a50

Please sign in to comment.