st/oxr: Use space graph in global-to-local space transform

This takes care of transforming the velocities.
This commit is contained in:
Christoph Haag 2020-09-11 19:05:25 +02:00
parent 150b7649f3
commit ddf3eb5789
2 changed files with 11 additions and 9 deletions

View file

@ -704,7 +704,7 @@ bool
initial_head_relation_valid(struct oxr_session *sess); initial_head_relation_valid(struct oxr_session *sess);
bool 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);
/* /*
* *

View file

@ -161,16 +161,18 @@ initial_head_relation_valid(struct oxr_session *sess)
} }
bool 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)) { if (!initial_head_relation_valid(sess)) {
return false; return false;
} }
struct xrt_pose inverse_initial_head_pose; struct xrt_space_graph graph = {0};
math_pose_invert(&sess->initial_head_relation.pose, m_space_graph_add_relation(&graph, rel);
&inverse_initial_head_pose); m_space_graph_add_inverted_pose_if_not_identity(
math_pose_transform(&inverse_initial_head_pose, pose, pose); &graph, &sess->initial_head_relation.pose);
m_space_graph_resolve(&graph, rel);
return true; return true;
} }
@ -203,7 +205,7 @@ oxr_space_ref_relation(struct oxr_logger *log,
if (baseSpc == XR_REFERENCE_SPACE_TYPE_STAGE) { if (baseSpc == XR_REFERENCE_SPACE_TYPE_STAGE) {
// device poses are already in stage = "global" space // device poses are already in stage = "global" space
} else if (baseSpc == XR_REFERENCE_SPACE_TYPE_LOCAL) { } 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 if (baseSpc == XR_REFERENCE_SPACE_TYPE_VIEW) {
} else { } else {
@ -225,7 +227,7 @@ oxr_space_ref_relation(struct oxr_logger *log,
if (space == XR_REFERENCE_SPACE_TYPE_STAGE) { if (space == XR_REFERENCE_SPACE_TYPE_STAGE) {
// device poses are already in stage = "global" space // device poses are already in stage = "global" space
} else if (space == XR_REFERENCE_SPACE_TYPE_LOCAL) { } 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 if (space == XR_REFERENCE_SPACE_TYPE_VIEW) {
} else { } else {
@ -341,7 +343,7 @@ oxr_space_action_relation(struct oxr_logger *log,
input->input->name, at_time, out_relation); input->input->name, at_time, out_relation);
if (baseSpc->type == XR_REFERENCE_SPACE_TYPE_LOCAL) { 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) { if (invert) {