Skip to content

Commit

Permalink
feat(server_openvr): ✨ Add option to disable hand skeleton prediction (
Browse files Browse the repository at this point in the history
…#2517)

* feat(server_openvr): ✨ Add option to disable hand skeleton prediction

* Add `predict` help string
  • Loading branch information
zmerp authored Nov 17, 2024
1 parent f86d34e commit 41e1037
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion alvr/server_openvr/cpp/alvr_server/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ bool Controller::OnPoseUpdate(uint64_t targetTimestampNs, float predictionS, Ffi
double linearVelocity[3] = { 0.0, 0.0, 0.0 };
vr::HmdVector3d_t angularVelocity = { 0.0, 0.0, 0.0 };

if (this->last_pose.poseIsValid) {
if (handData.predictHandSkeleton && this->last_pose.poseIsValid) {
double dt = ((double)targetTimestampNs - (double)m_poseTargetTimestampNs) / NS_PER_S;

if (dt > 0.0) {
Expand Down
1 change: 1 addition & 0 deletions alvr/server_openvr/cpp/alvr_server/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct FfiHandData {
const FfiDeviceMotion* controllerMotion;
const FfiHandSkeleton* handSkeleton;
bool isHandTracker;
bool predictHandSkeleton;
};

enum FfiOpenvrPropertyType {
Expand Down
6 changes: 5 additions & 1 deletion alvr/server_openvr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ extern "C" fn driver_ready_idle(set_default_chap: bool) {
use_separate_hand_trackers,
ffi_left_hand_skeleton,
ffi_right_hand_skeleton,
predict_hand_skeleton,
) = if let Some(ControllersConfig {
hand_skeleton: Switch::Enabled(hand_skeleton_config),
..
Expand Down Expand Up @@ -166,9 +167,10 @@ extern "C" fn driver_ready_idle(set_default_chap: bool) {
hand_skeleton_config.steamvr_input_2_0,
tracked.then_some(left_hand_skeleton).flatten(),
tracked.then_some(right_hand_skeleton).flatten(),
hand_skeleton_config.predict,
)
} else {
(false, None, None)
(false, None, None, false)
};

let ffi_left_hand_data = FfiHandData {
Expand All @@ -185,6 +187,7 @@ extern "C" fn driver_ready_idle(set_default_chap: bool) {
isHandTracker: use_separate_hand_trackers
&& ffi_left_controller_motion.is_none()
&& ffi_left_hand_skeleton.is_some(),
predictHandSkeleton: predict_hand_skeleton,
};
let ffi_right_hand_data = FfiHandData {
controllerMotion: if let Some(motion) = &ffi_right_controller_motion {
Expand All @@ -200,6 +203,7 @@ extern "C" fn driver_ready_idle(set_default_chap: bool) {
isHandTracker: use_separate_hand_trackers
&& ffi_right_controller_motion.is_none()
&& ffi_right_hand_skeleton.is_some(),
predictHandSkeleton: predict_hand_skeleton,
};

let ffi_body_tracker_motions = if track_body {
Expand Down
7 changes: 7 additions & 0 deletions alvr/session/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,12 @@ pub struct HandSkeletonConfig {
help = r"Enabling this will use separate tracker objects with the full skeletal tracking level when hand tracking is detected. This is required for VRChat hand tracking."
))]
pub steamvr_input_2_0: bool,

#[schema(flag = "real-time")]
#[schema(strings(
help = r"Predict hand skeleton to make it less floaty. It may make hands too jittery."
))]
pub predict: bool,
}

#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -1628,6 +1634,7 @@ pub fn session_settings_default() -> SettingsDefault {
enabled: true,
content: HandSkeletonConfigDefault {
steamvr_input_2_0: true,
predict: false,
},
},
multimodal_tracking: false,
Expand Down

0 comments on commit 41e1037

Please sign in to comment.