From ddf3eb5789d5fda4b7d97164e251602d29aea44e Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Fri, 11 Sep 2020 19:05:25 +0200 Subject: [PATCH] st/oxr: Use space graph in global-to-local space transform This takes care of transforming the velocities. --- src/xrt/state_trackers/oxr/oxr_objects.h | 2 +- src/xrt/state_trackers/oxr/oxr_space.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index 4880d77ee..f21952e39 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -704,7 +704,7 @@ bool initial_head_relation_valid(struct oxr_session *sess); bool -global_to_local_space(struct oxr_session *sess, struct xrt_pose *pose); +global_to_local_space(struct oxr_session *sess, struct xrt_space_relation *rel); /* * diff --git a/src/xrt/state_trackers/oxr/oxr_space.c b/src/xrt/state_trackers/oxr/oxr_space.c index 6b10c2cfe..fb225c418 100644 --- a/src/xrt/state_trackers/oxr/oxr_space.c +++ b/src/xrt/state_trackers/oxr/oxr_space.c @@ -161,16 +161,18 @@ initial_head_relation_valid(struct oxr_session *sess) } bool -global_to_local_space(struct oxr_session *sess, struct xrt_pose *pose) +global_to_local_space(struct oxr_session *sess, struct xrt_space_relation *rel) { if (!initial_head_relation_valid(sess)) { return false; } - struct xrt_pose inverse_initial_head_pose; - math_pose_invert(&sess->initial_head_relation.pose, - &inverse_initial_head_pose); - math_pose_transform(&inverse_initial_head_pose, pose, pose); + struct xrt_space_graph graph = {0}; + m_space_graph_add_relation(&graph, rel); + m_space_graph_add_inverted_pose_if_not_identity( + &graph, &sess->initial_head_relation.pose); + m_space_graph_resolve(&graph, rel); + return true; } @@ -203,7 +205,7 @@ oxr_space_ref_relation(struct oxr_logger *log, if (baseSpc == XR_REFERENCE_SPACE_TYPE_STAGE) { // device poses are already in stage = "global" space } else if (baseSpc == XR_REFERENCE_SPACE_TYPE_LOCAL) { - global_to_local_space(sess, &out_relation->pose); + global_to_local_space(sess, out_relation); } else if (baseSpc == XR_REFERENCE_SPACE_TYPE_VIEW) { } else { @@ -225,7 +227,7 @@ oxr_space_ref_relation(struct oxr_logger *log, if (space == XR_REFERENCE_SPACE_TYPE_STAGE) { // device poses are already in stage = "global" space } else if (space == XR_REFERENCE_SPACE_TYPE_LOCAL) { - global_to_local_space(sess, &out_relation->pose); + global_to_local_space(sess, out_relation); } else if (space == XR_REFERENCE_SPACE_TYPE_VIEW) { } else { @@ -341,7 +343,7 @@ oxr_space_action_relation(struct oxr_logger *log, input->input->name, at_time, out_relation); if (baseSpc->type == XR_REFERENCE_SPACE_TYPE_LOCAL) { - global_to_local_space(sess, &out_relation->pose); + global_to_local_space(sess, out_relation); } if (invert) {