The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrt: Rename xrt_space_graph to xrt_relation_chain.

Rename all functions and instances accordingly as well,
and add documentation for all methods.

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
c9889f77 67061123

+221 -183
+1
doc/changes/xrt/mr.1092.md
··· 1 + Rename `xrt_space_graph` (and related `m_space_graph_*` functions in `m_space.h`) to `xrt_relation_chain` to more accurately reflect the function of this structure.
+17 -17
src/xrt/auxiliary/math/m_space.cpp
··· 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file 5 - * @brief Functions for manipulating a @ref xrt_space_graph struct. 5 + * @brief Functions for manipulating a @ref xrt_relation_chain struct. 6 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 7 * @ingroup aux_math 8 8 */ ··· 61 61 } 62 62 63 63 static void 64 - dump_graph(const struct xrt_space_graph *xsg) 64 + dump_chain(const struct xrt_relation_chain *xrc) 65 65 { 66 - fprintf(stderr, "%s %u\n", __func__, xsg->step_count); 67 - for (uint32_t i = 0; i < xsg->step_count; i++) { 68 - const struct xrt_space_relation *r = &xsg->steps[i]; 66 + fprintf(stderr, "%s %u\n", __func__, xrc->step_count); 67 + for (uint32_t i = 0; i < xrc->step_count; i++) { 68 + const struct xrt_space_relation *r = &xrc->steps[i]; 69 69 fprintf(stderr, "\t%2u: ", i); 70 70 dump_relation(r); 71 71 } ··· 79 79 */ 80 80 81 81 static bool 82 - has_step_with_no_pose(const struct xrt_space_graph *xsg) 82 + has_step_with_no_pose(const struct xrt_relation_chain *xrc) 83 83 { 84 84 const enum xrt_space_relation_flags pose_flags = (enum xrt_space_relation_flags)( 85 85 XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_VALID_BIT); 86 86 87 - for (uint32_t i = 0; i < xsg->step_count; i++) { 88 - const struct xrt_space_relation *r = &xsg->steps[i]; 87 + for (uint32_t i = 0; i < xrc->step_count; i++) { 88 + const struct xrt_space_relation *r = &xrc->steps[i]; 89 89 if ((r->relation_flags & pose_flags) == 0) { 90 90 return true; 91 91 } ··· 216 216 struct xrt_pose body_pose = XRT_POSE_IDENTITY; 217 217 struct xrt_pose base_pose = XRT_POSE_IDENTITY; 218 218 219 - // Only valid poses handled in graph. Flags are determined later. 219 + // Only valid poses handled in chain. Flags are determined later. 220 220 make_valid_pose(af, &a->pose, &body_pose); 221 221 make_valid_pose(bf, &b->pose, &base_pose); 222 222 ··· 276 276 */ 277 277 278 278 void 279 - m_space_graph_resolve(const struct xrt_space_graph *xsg, struct xrt_space_relation *out_relation) 279 + m_relation_chain_resolve(const struct xrt_relation_chain *xrc, struct xrt_space_relation *out_relation) 280 280 { 281 - if (xsg->step_count == 0 || has_step_with_no_pose(xsg)) { 281 + if (xrc->step_count == 0 || has_step_with_no_pose(xrc)) { 282 282 *out_relation = XRT_SPACE_RELATION_ZERO; 283 283 return; 284 284 } 285 285 286 - struct xrt_space_relation r = xsg->steps[0]; 287 - for (uint32_t i = 1; i < xsg->step_count; i++) { 288 - apply_relation(&r, &xsg->steps[i], &r); 286 + struct xrt_space_relation r = xrc->steps[0]; 287 + for (uint32_t i = 1; i < xrc->step_count; i++) { 288 + apply_relation(&r, &xrc->steps[i], &r); 289 289 } 290 290 291 291 #if 0 292 - dump_graph(xsg); 292 + dump_chain(xrc); 293 293 fprintf(stderr, "\tRR: "); 294 294 dump_relation(&r); 295 295 #else 296 - (void)dump_graph; 296 + (void)dump_chain; 297 297 #endif 298 298 299 - // Ensure no errors has crept in. 299 + // Ensure no errors have crept in. 300 300 math_quat_normalize(&r.pose.orientation); 301 301 302 302 *out_relation = r;
+55 -20
src/xrt/auxiliary/math/m_space.h
··· 3 3 /*! 4 4 * @file 5 5 * @brief Functions for manipulating @ref xrt_pose, @ref xrt_space_relation and 6 - * @ref xrt_space_graph structs. 6 + * @ref xrt_relation_chain structs. 7 7 * @author Jakob Bornecrantz <jakob@collabora.com> 8 8 * @ingroup aux_math 9 9 */ ··· 85 85 86 86 /* 87 87 * 88 - * Space graph functions. 88 + * Relation chain functions. 89 89 * 90 90 */ 91 91 92 92 /*! 93 - * Reserve a step in the graph and return a pointer to the relation. 93 + * Reserve a step in the chain and return a pointer to the relation. 94 + * 95 + * @note The data pointed to by the returned pointer is not initialized: 96 + * you must populate it before using @ref m_relation_chain_resolve 97 + * 98 + * @public @memberof xrt_relation_chain 94 99 */ 95 100 static inline struct xrt_space_relation * 96 - m_space_graph_reserve(struct xrt_space_graph *xsg) 101 + m_relation_chain_reserve(struct xrt_relation_chain *xrc) 97 102 { 98 - if (xsg->step_count < XRT_SPACE_GRAPHS_MAX) { 99 - return &xsg->steps[xsg->step_count++]; 103 + if (xrc->step_count < XRT_RELATION_CHAIN_CAPACITY) { 104 + return &xrc->steps[xrc->step_count++]; 100 105 } else { 101 106 return NULL; 102 107 } 103 108 } 104 109 105 110 /*! 106 - * Flattens a space graph into a single relation. 111 + * Append a new relation 112 + * 113 + * @public @memberof xrt_relation_chain 107 114 */ 108 115 static inline void 109 - m_space_graph_add_relation(struct xrt_space_graph *xsg, const struct xrt_space_relation *relation) 116 + m_relation_chain_push_relation(struct xrt_relation_chain *xrc, const struct xrt_space_relation *relation) 110 117 { 111 - if (xsg->step_count >= XRT_SPACE_GRAPHS_MAX) { 118 + if (xrc->step_count >= XRT_RELATION_CHAIN_CAPACITY) { 112 119 return; 113 120 } 114 121 115 - xsg->steps[xsg->step_count++] = *relation; 122 + xrc->steps[xrc->step_count++] = *relation; 116 123 } 117 124 125 + /*! 126 + * Append the inverse of the provided relation. 127 + * 128 + * Validity flags stay the same, only the pose and velocities are inverted. 129 + * 130 + * @public @memberof xrt_relation_chain 131 + */ 118 132 static inline void 119 - m_space_graph_add_inverted_relation(struct xrt_space_graph *xsg, const struct xrt_space_relation *relation) 133 + m_relation_chain_push_inverted_relation(struct xrt_relation_chain *xrc, const struct xrt_space_relation *relation) 120 134 { 121 135 struct xrt_space_relation r = *relation; 122 136 123 137 struct xrt_space_relation invert; 124 138 m_space_relation_invert(&r, &invert); 125 - m_space_graph_add_relation(xsg, &invert); 139 + m_relation_chain_push_relation(xrc, &invert); 126 140 } 127 141 142 + /*! 143 + * Append a new pose as a relation without velocity 144 + * 145 + * @public @memberof xrt_relation_chain 146 + */ 128 147 static inline void 129 - m_space_graph_add_pose(struct xrt_space_graph *xsg, const struct xrt_pose *pose) 148 + m_relation_chain_push_pose(struct xrt_relation_chain *xrc, const struct xrt_pose *pose) 130 149 { 131 150 struct xrt_space_relation relation; 132 151 m_space_relation_from_pose(pose, &relation); 133 - m_space_graph_add_relation(xsg, &relation); 152 + m_relation_chain_push_relation(xrc, &relation); 134 153 } 135 154 155 + /*! 156 + * Append a new pose as a relation without velocity, if it is not the identity pose. 157 + * 158 + * @public @memberof xrt_relation_chain 159 + */ 136 160 static inline void 137 - m_space_graph_add_pose_if_not_identity(struct xrt_space_graph *xsg, const struct xrt_pose *pose) 161 + m_relation_chain_push_pose_if_not_identity(struct xrt_relation_chain *xrc, const struct xrt_pose *pose) 138 162 { 139 163 struct xrt_pose p = *pose; 140 164 ··· 142 166 return; 143 167 } 144 168 145 - m_space_graph_add_pose(xsg, &p); 169 + m_relation_chain_push_pose(xrc, &p); 146 170 } 147 171 172 + /*! 173 + * Append the inverse of a pose as a relation without velocity, if it is not the identity pose. 174 + * 175 + * Validity flags stay the same, only the pose is inverted. 176 + * 177 + * @public @memberof xrt_relation_chain 178 + */ 148 179 static inline void 149 - m_space_graph_add_inverted_pose_if_not_identity(struct xrt_space_graph *xsg, const struct xrt_pose *pose) 180 + m_relation_chain_push_inverted_pose_if_not_identity(struct xrt_relation_chain *xrc, const struct xrt_pose *pose) 150 181 { 151 182 struct xrt_pose p = *pose; 152 183 ··· 156 187 157 188 struct xrt_pose invert; 158 189 math_pose_invert(&p, &invert); 159 - m_space_graph_add_pose(xsg, &invert); 190 + m_relation_chain_push_pose(xrc, &invert); 160 191 } 161 192 162 193 /*! 163 - * Flattens a space graph into a single relation. 194 + * Compute the equivalent single relation from flattening a relation chain. 195 + * 196 + * The input chain is not modified. 197 + * 198 + * @public @memberof xrt_relation_chain 164 199 */ 165 200 void 166 - m_space_graph_resolve(const struct xrt_space_graph *xsg, struct xrt_space_relation *out_relation); 201 + m_relation_chain_resolve(const struct xrt_relation_chain *xrc, struct xrt_space_relation *out_relation); 167 202 168 203 /*! 169 204 * @}
+5 -5
src/xrt/auxiliary/util/u_hand_tracking.c
··· 662 662 l[i].relation.relation_flags |= data->relation.relation_flags; 663 663 l[i].radius = hand_joint_default_set_curl_model_defaults[i].radius; 664 664 665 - struct xrt_space_graph graph = {0}; 666 - m_space_graph_add_relation(&graph, &data->relation); 667 - m_space_graph_add_pose(&graph, hand_offset); 668 - m_space_graph_resolve(&graph, &l[i].relation); 665 + struct xrt_relation_chain chain = {0}; 666 + m_relation_chain_push_relation(&chain, &data->relation); 667 + m_relation_chain_push_pose(&chain, hand_offset); 668 + m_relation_chain_resolve(&chain, &l[i].relation); 669 669 670 670 // joint relations can not be "more valid" than the hand relation 671 - // after space graph to make sure flags are not "upgraded" 671 + // after relation chain to make sure flags are not "upgraded" 672 672 l[i].relation.relation_flags &= hand_relation->relation_flags; 673 673 } 674 674
+10 -10
src/xrt/compositor/main/comp_renderer.c
··· 635 635 xrt_device_get_view_pose(r->c->xdev, &eye_relation, i, &eye_pose); 636 636 637 637 struct xrt_space_relation result = {0}; 638 - struct xrt_space_graph xsg = {0}; 639 - m_space_graph_add_pose_if_not_identity(&xsg, &eye_pose); 640 - m_space_graph_add_relation(&xsg, &relation); 641 - m_space_graph_add_pose_if_not_identity(&xsg, &base_space_pose); 642 - m_space_graph_resolve(&xsg, &result); 638 + struct xrt_relation_chain xrc = {0}; 639 + m_relation_chain_push_pose_if_not_identity(&xrc, &eye_pose); 640 + m_relation_chain_push_relation(&xrc, &relation); 641 + m_relation_chain_push_pose_if_not_identity(&xrc, &base_space_pose); 642 + m_relation_chain_resolve(&xrc, &result); 643 643 644 644 comp_layer_renderer_set_pose(r->lr, &eye_pose, &result.pose, i); 645 645 } ··· 876 876 &relation); // 877 877 878 878 struct xrt_vec3 eye_relation = { 879 - 0.063000f, /* TODO: get actual ipd_meters */ 879 + 0.063000f, /*! @todo get actual ipd_meters */ 880 880 0.0f, 881 881 0.0f, 882 882 }; ··· 890 890 xrt_device_get_view_pose(r->c->xdev, &eye_relation, i, &eye_pose); 891 891 892 892 struct xrt_space_relation result = {0}; 893 - struct xrt_space_graph xsg = {0}; 894 - m_space_graph_add_pose_if_not_identity(&xsg, &eye_pose); 895 - m_space_graph_add_relation(&xsg, &relation); 896 - m_space_graph_resolve(&xsg, &result); 893 + struct xrt_relation_chain xrc = {0}; 894 + m_relation_chain_push_pose_if_not_identity(&xrc, &eye_pose); 895 + m_relation_chain_push_relation(&xrc, &relation); 896 + m_relation_chain_resolve(&xrc, &result); 897 897 898 898 out_results[i] = result.pose; 899 899 }
+4 -4
src/xrt/drivers/euroc/euroc_device.c
··· 150 150 } 151 151 } 152 152 153 - struct xrt_space_graph space_graph = {0}; 154 - m_space_graph_add_pose(&space_graph, &ed->pose); 155 - m_space_graph_add_pose(&space_graph, &ed->offset); 156 - m_space_graph_resolve(&space_graph, out_relation); 153 + struct xrt_relation_chain relation_chain = {0}; 154 + m_relation_chain_push_pose(&relation_chain, &ed->pose); 155 + m_relation_chain_push_pose(&relation_chain, &ed->offset); 156 + m_relation_chain_resolve(&relation_chain, out_relation); 157 157 out_relation->relation_flags = (enum xrt_space_relation_flags)( 158 158 XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | 159 159 XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT);
+12 -12
src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp
··· 152 152 joint_position_global(xrt_hand_joint_set *joint_set, xrt_hand_joint joint) 153 153 { 154 154 struct xrt_space_relation out_relation; 155 - struct xrt_space_graph xsg = {}; 156 - m_space_graph_add_relation(&xsg, &joint_set->values.hand_joint_set_default[joint].relation); 157 - m_space_graph_add_relation(&xsg, &joint_set->hand_pose); 158 - m_space_graph_resolve(&xsg, &out_relation); 155 + struct xrt_relation_chain xrc = {}; 156 + m_relation_chain_push_relation(&xrc, &joint_set->values.hand_joint_set_default[joint].relation); 157 + m_relation_chain_push_relation(&xrc, &joint_set->hand_pose); 158 + m_relation_chain_resolve(&xrc, &out_relation); 159 159 return out_relation.pose.position; 160 160 } 161 161 ··· 163 163 joint_pose_global(xrt_hand_joint_set *joint_set, xrt_hand_joint joint) 164 164 { 165 165 struct xrt_space_relation out_relation; 166 - struct xrt_space_graph xsg = {}; 167 - m_space_graph_add_relation(&xsg, &joint_set->values.hand_joint_set_default[joint].relation); 168 - m_space_graph_add_relation(&xsg, &joint_set->hand_pose); 169 - m_space_graph_resolve(&xsg, &out_relation); 166 + struct xrt_relation_chain xrc = {}; 167 + m_relation_chain_push_relation(&xrc, &joint_set->values.hand_joint_set_default[joint].relation); 168 + m_relation_chain_push_relation(&xrc, &joint_set->hand_pose); 169 + m_relation_chain_resolve(&xrc, &out_relation); 170 170 return out_relation.pose; 171 171 } 172 172 ··· 183 183 xrt_pose palm = joint_pose_global(joint_set, XRT_HAND_JOINT_PALM); 184 184 185 185 // Position. 186 - struct xrt_space_graph xsg = {}; 187 - m_space_graph_add_pose(&xsg, &offset_from_palm); 188 - m_space_graph_add_pose(&xsg, &palm); 189 - m_space_graph_resolve(&xsg, out_relation); 186 + struct xrt_relation_chain xrc = {}; 187 + m_relation_chain_push_pose(&xrc, &offset_from_palm); 188 + m_relation_chain_push_pose(&xrc, &palm); 189 + m_relation_chain_resolve(&xrc, out_relation); 190 190 191 191 192 192 // Orientation.
+13 -13
src/xrt/drivers/multi_wrapper/multi.c
··· 43 43 struct xrt_space_relation *tracker_relation, 44 44 struct xrt_space_relation *out_relation) 45 45 { 46 - struct xrt_space_graph xsg = {0}; 47 - m_space_graph_add_pose_if_not_identity(&xsg, &d->tracking_override.offset_inv); 48 - m_space_graph_add_relation(&xsg, tracker_relation); 49 - m_space_graph_resolve(&xsg, out_relation); 46 + struct xrt_relation_chain xrc = {0}; 47 + m_relation_chain_push_pose_if_not_identity(&xrc, &d->tracking_override.offset_inv); 48 + m_relation_chain_push_relation(&xrc, tracker_relation); 49 + m_relation_chain_resolve(&xrc, out_relation); 50 50 } 51 51 52 52 static void ··· 65 65 */ 66 66 67 67 // XXX TODO tracking origin offsets 68 - // m_space_graph_add_inverted_pose_if_not_identity(&xsg, tracker_offset); 69 - // m_space_graph_add_inverted_relation(&xsg, tracker_relation); 68 + // m_relation_chain_push_inverted_pose_if_not_identity(&xrc, tracker_offset); 69 + // m_relation_chain_push_inverted_relation(&xrc, tracker_relation); 70 70 71 - struct xrt_space_graph xsg = {0}; 72 - m_space_graph_add_relation(&xsg, target_relation); 73 - m_space_graph_add_pose_if_not_identity(&xsg, &d->tracking_override.offset_inv); 74 - m_space_graph_add_relation(&xsg, tracker_relation); 75 - m_space_graph_add_pose_if_not_identity(&xsg, tracker_offset); 76 - m_space_graph_add_relation(&xsg, in_target_space); 77 - m_space_graph_resolve(&xsg, out_relation); 71 + struct xrt_relation_chain xrc = {0}; 72 + m_relation_chain_push_relation(&xrc, target_relation); 73 + m_relation_chain_push_pose_if_not_identity(&xrc, &d->tracking_override.offset_inv); 74 + m_relation_chain_push_relation(&xrc, tracker_relation); 75 + m_relation_chain_push_pose_if_not_identity(&xrc, tracker_offset); 76 + m_relation_chain_push_relation(&xrc, in_target_space); 77 + m_relation_chain_resolve(&xrc, out_relation); 78 78 } 79 79 80 80 static void
+11 -11
src/xrt/drivers/psmv/psmv_driver.c
··· 792 792 } 793 793 794 794 static void 795 - psmv_add_pose_offset(enum xrt_input_name name, struct xrt_space_graph *xsg) 795 + psmv_push_pose_offset(enum xrt_input_name name, struct xrt_relation_chain *xrc) 796 796 { 797 797 /* 798 798 * Both the grip and aim pose needs adjustments, the grip is a rotated ··· 814 814 {0, y, 0}, 815 815 }; 816 816 817 - m_space_graph_add_pose(xsg, &pose); 817 + m_relation_chain_push_pose(xrc, &pose); 818 818 } 819 819 820 820 ··· 883 883 } 884 884 885 885 static xrt_result_t 886 - psmv_device_get_space_graph(struct xrt_device *xdev, 887 - enum xrt_input_name name, 888 - uint64_t at_timestamp_ns, 889 - struct xrt_space_graph *xgs) 886 + psmv_device_get_relation_chain(struct xrt_device *xdev, 887 + enum xrt_input_name name, 888 + uint64_t at_timestamp_ns, 889 + struct xrt_relation_chain *xrc) 890 890 { 891 891 struct psmv_device *psmv = psmv_device(xdev); 892 892 893 - psmv_add_pose_offset(name, xgs); 893 + psmv_push_pose_offset(name, xrc); 894 894 895 - struct xrt_space_relation *rel = m_space_graph_reserve(xgs); 895 + struct xrt_space_relation *rel = m_relation_chain_reserve(xrc); 896 896 897 897 if (psmv->ball != NULL) { 898 898 xrt_tracked_psmv_get_tracked_pose(psmv->ball, name, at_timestamp_ns, rel); ··· 909 909 uint64_t at_timestamp_ns, 910 910 struct xrt_space_relation *out_relation) 911 911 { 912 - struct xrt_space_graph xgs = {0}; 912 + struct xrt_relation_chain xrc = {0}; 913 913 914 - psmv_device_get_space_graph(xdev, name, at_timestamp_ns, &xgs); 914 + psmv_device_get_relation_chain(xdev, name, at_timestamp_ns, &xrc); 915 915 916 - m_space_graph_resolve(&xgs, out_relation); 916 + m_relation_chain_resolve(&xrc, out_relation); 917 917 } 918 918 919 919 static float
+10 -10
src/xrt/drivers/qwerty/qwerty_device.c
··· 190 190 bool qd_is_ctrl = name == XRT_INPUT_SIMPLE_GRIP_POSE; 191 191 struct qwerty_controller *qc = qd_is_ctrl ? qwerty_controller(&qd->base) : NULL; 192 192 if (qd_is_ctrl && qc->follow_hmd) { 193 - struct xrt_space_graph space_graph = {0}; 193 + struct xrt_relation_chain relation_chain = {0}; 194 194 struct qwerty_device *qd_hmd = &qd->sys->hmd->base; 195 - m_space_graph_add_pose(&space_graph, &qd->pose); // controller pose 196 - m_space_graph_add_pose(&space_graph, &qd_hmd->pose); // base space is hmd space 197 - m_space_graph_resolve(&space_graph, out_relation); 195 + m_relation_chain_push_pose(&relation_chain, &qd->pose); // controller pose 196 + m_relation_chain_push_pose(&relation_chain, &qd_hmd->pose); // base space is hmd space 197 + m_relation_chain_resolve(&relation_chain, out_relation); 198 198 } else { 199 199 out_relation->pose = qd->pose; 200 200 } ··· 515 515 } 516 516 517 517 struct qwerty_device *qd_hmd = &qd->sys->hmd->base; 518 - struct xrt_space_graph graph = {0}; 519 - struct xrt_space_relation rel = {0}; 518 + struct xrt_relation_chain chain = {0}; 519 + struct xrt_space_relation rel = XRT_SPACE_RELATION_ZERO; 520 520 521 - m_space_graph_add_pose(&graph, &qd->pose); 521 + m_relation_chain_push_pose(&chain, &qd->pose); 522 522 if (follow) { // From global to hmd 523 - m_space_graph_add_inverted_pose_if_not_identity(&graph, &qd_hmd->pose); 523 + m_relation_chain_push_inverted_pose_if_not_identity(&chain, &qd_hmd->pose); 524 524 } else { // From hmd to global 525 - m_space_graph_add_pose(&graph, &qd_hmd->pose); 525 + m_relation_chain_push_pose(&chain, &qd_hmd->pose); 526 526 } 527 - m_space_graph_resolve(&graph, &rel); 527 + m_relation_chain_resolve(&chain, &rel); 528 528 529 529 qd->pose = rel.pose; 530 530 qc->follow_hmd = follow;
+13 -13
src/xrt/drivers/realsense/rs_hdev.c
··· 221 221 // Correct orientation 222 222 //! @todo Encode this transformation into constants 223 223 struct xrt_space_relation out_relation; 224 - struct xrt_space_graph space_graph = {0}; 224 + struct xrt_relation_chain relation_chain = {0}; 225 225 struct xrt_pose pre_correction = {{-0.5, -0.5, -0.5, 0.5}, {0, 0, 0}}; // euler(90, 90, 0) 226 226 float sin45 = 0.7071067811865475; 227 227 struct xrt_pose pos_correction = {{sin45, 0, sin45, 0}, {0, 0, 0}}; // euler(180, 90, 0) 228 - m_space_graph_add_pose(&space_graph, &pre_correction); 229 - m_space_graph_add_pose(&space_graph, &swapped); 230 - m_space_graph_add_pose(&space_graph, &pos_correction); 231 - m_space_graph_resolve(&space_graph, &out_relation); 228 + m_relation_chain_push_pose(&relation_chain, &pre_correction); 229 + m_relation_chain_push_pose(&relation_chain, &swapped); 230 + m_relation_chain_push_pose(&relation_chain, &pos_correction); 231 + m_relation_chain_resolve(&relation_chain, &out_relation); 232 232 return out_relation.pose; 233 233 } 234 234 ··· 249 249 // Correct orientation 250 250 //! @todo Encode this transformation into constants 251 251 struct xrt_space_relation out_relation; 252 - struct xrt_space_graph space_graph = {0}; 252 + struct xrt_relation_chain relation_chain = {0}; 253 253 const float sin45 = 0.7071067811865475; 254 254 struct xrt_pose pos_correction = {{sin45, 0, 0, sin45}, {0, 0, 0}}; // euler(90, 0, 0) 255 255 256 - m_space_graph_add_pose(&space_graph, &swapped); 257 - m_space_graph_add_pose(&space_graph, &pos_correction); 258 - m_space_graph_resolve(&space_graph, &out_relation); 256 + m_relation_chain_push_pose(&relation_chain, &swapped); 257 + m_relation_chain_push_pose(&relation_chain, &pos_correction); 258 + m_relation_chain_resolve(&relation_chain, &out_relation); 259 259 return out_relation.pose; 260 260 } 261 261 ··· 284 284 #endif 285 285 } 286 286 287 - struct xrt_space_graph space_graph = {0}; 288 - m_space_graph_add_pose(&space_graph, &rh->pose); 289 - m_space_graph_add_pose(&space_graph, &rh->offset); 290 - m_space_graph_resolve(&space_graph, out_relation); 287 + struct xrt_relation_chain relation_chain = {0}; 288 + m_relation_chain_push_pose(&relation_chain, &rh->pose); 289 + m_relation_chain_push_pose(&relation_chain, &rh->offset); 290 + m_relation_chain_resolve(&relation_chain, out_relation); 291 291 out_relation->relation_flags = (enum xrt_space_relation_flags)( 292 292 XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | 293 293 XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT);
+8 -8
src/xrt/include/xrt/xrt_defines.h
··· 486 486 } 487 487 488 488 /*! 489 - * The maximum number of steps that can be in a space graph chain. 489 + * The maximum number of steps that can be in a relation chain. 490 490 * 491 - * @see xrt_space_graph::steps 491 + * @see xrt_relation_chain::steps 492 + * @relates xrt_relation_chain 492 493 * @ingroup xrt_iface math 493 494 */ 494 - #define XRT_SPACE_GRAPHS_MAX 8 495 + #define XRT_RELATION_CHAIN_CAPACITY 8 495 496 496 497 /*! 497 - * A graph of space relations, technically more of a chain of transformation 498 - * since it's not branching, but a flat graph is still a graph. Functions for 499 - * manipulating this are available in `math/m_space.h`. 498 + * A chain of space relations and their associated validity flags. 499 + * Functions for manipulating this are available in `math/m_space.h`. 500 500 * 501 501 * @see xrt_space_relation 502 502 * @ingroup xrt_iface math 503 503 */ 504 - struct xrt_space_graph 504 + struct xrt_relation_chain 505 505 { 506 - struct xrt_space_relation steps[XRT_SPACE_GRAPHS_MAX]; 506 + struct xrt_space_relation steps[XRT_RELATION_CHAIN_CAPACITY]; 507 507 uint32_t step_count; 508 508 }; 509 509
+6 -6
src/xrt/state_trackers/oxr/oxr_objects.h
··· 885 885 oxr_xdev_find_output(struct xrt_device *xdev, enum xrt_output_name name, struct xrt_output **out_output); 886 886 887 887 void 888 - oxr_xdev_get_space_graph(struct oxr_logger *log, 889 - struct oxr_instance *inst, 890 - struct xrt_device *xdev, 891 - enum xrt_input_name name, 892 - XrTime at_time, 893 - struct xrt_space_graph *xsg); 888 + oxr_xdev_get_relation_chain(struct oxr_logger *log, 889 + struct oxr_instance *inst, 890 + struct xrt_device *xdev, 891 + enum xrt_input_name name, 892 + XrTime at_time, 893 + struct xrt_relation_chain *xrc); 894 894 895 895 void 896 896 oxr_xdev_get_space_relation(struct oxr_logger *log,
+26 -24
src/xrt/state_trackers/oxr/oxr_session.c
··· 281 281 struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); 282 282 283 283 // Applies the offset in the function. 284 - struct xrt_space_graph xsg = {0}; 285 - oxr_xdev_get_space_graph(log, sess->sys->inst, xdev, XRT_INPUT_GENERIC_HEAD_POSE, at_time, &xsg); 286 - m_space_graph_resolve(&xsg, out_relation); 284 + struct xrt_relation_chain xrc = {0}; 285 + oxr_xdev_get_relation_chain(log, sess->sys->inst, xdev, XRT_INPUT_GENERIC_HEAD_POSE, at_time, &xrc); 286 + m_relation_chain_resolve(&xrc, out_relation); 287 287 288 288 return oxr_session_success_result(sess); 289 289 } ··· 396 396 397 397 // Do the magical space relation dance here. 398 398 struct xrt_space_relation result = {0}; 399 - struct xrt_space_graph xsg = {0}; 400 - m_space_graph_add_pose_if_not_identity(&xsg, &view_pose); 401 - m_space_graph_add_relation(&xsg, &pure_relation); 402 - m_space_graph_add_pose_if_not_identity(&xsg, &baseSpc->pose); 403 - m_space_graph_resolve(&xsg, &result); 399 + struct xrt_relation_chain xrc = {0}; 400 + m_relation_chain_push_pose_if_not_identity(&xrc, &view_pose); 401 + m_relation_chain_push_relation(&xrc, &pure_relation); 402 + m_relation_chain_push_pose_if_not_identity(&xrc, &baseSpc->pose); 403 + m_relation_chain_resolve(&xrc, &result); 404 404 union { 405 405 struct xrt_pose xrt; 406 406 struct XrPosef oxr; ··· 843 843 struct xrt_space_relation r = value.values.hand_joint_set_default[i].relation; 844 844 845 845 struct xrt_space_relation result; 846 - struct xrt_space_graph graph = {0}; 847 - m_space_graph_add_relation(&graph, &r); 846 + struct xrt_relation_chain chain = {0}; 847 + m_relation_chain_push_relation(&chain, &r); 848 848 849 849 850 850 if (baseSpc->type == XR_REFERENCE_SPACE_TYPE_STAGE) { 851 851 852 - m_space_graph_add_relation(&graph, &value.hand_pose); 853 - m_space_graph_add_pose_if_not_identity(&graph, tracking_origin_offset); 852 + m_relation_chain_push_relation(&chain, &value.hand_pose); 853 + m_relation_chain_push_pose_if_not_identity(&chain, tracking_origin_offset); 854 854 855 855 } else if (baseSpc->type == XR_REFERENCE_SPACE_TYPE_LOCAL) { 856 856 857 857 // for local space, first do stage space and transform 858 858 // result to local @todo: improve local space 859 - m_space_graph_add_relation(&graph, &value.hand_pose); 860 - m_space_graph_add_pose_if_not_identity(&graph, tracking_origin_offset); 859 + m_relation_chain_push_relation(&chain, &value.hand_pose); 860 + m_relation_chain_push_pose_if_not_identity(&chain, tracking_origin_offset); 861 861 862 862 } else if (baseSpc->type == XR_REFERENCE_SPACE_TYPE_VIEW) { 863 863 /*! @todo: testing, relating to view space unsupported ··· 868 868 struct xrt_space_relation view_relation; 869 869 oxr_session_get_view_relation_at(log, sess, at_time, &view_relation); 870 870 871 - m_space_graph_add_relation(&graph, &value.hand_pose); 872 - m_space_graph_add_pose_if_not_identity(&graph, tracking_origin_offset); 871 + m_relation_chain_push_relation(&chain, &value.hand_pose); 872 + m_relation_chain_push_pose_if_not_identity(&chain, tracking_origin_offset); 873 873 874 - m_space_graph_add_inverted_relation(&graph, &view_relation); 875 - m_space_graph_add_inverted_pose_if_not_identity(&graph, &head_xdev->tracking_origin->offset); 874 + m_relation_chain_push_inverted_relation(&chain, &view_relation); 875 + m_relation_chain_push_inverted_pose_if_not_identity(&chain, 876 + &head_xdev->tracking_origin->offset); 876 877 877 878 } else if (!baseSpc->is_reference) { 878 879 // action space ··· 892 893 &act_space_relation); 893 894 894 895 895 - m_space_graph_add_relation(&graph, &value.hand_pose); 896 - m_space_graph_add_pose_if_not_identity(&graph, tracking_origin_offset); 896 + m_relation_chain_push_relation(&chain, &value.hand_pose); 897 + m_relation_chain_push_pose_if_not_identity(&chain, tracking_origin_offset); 897 898 898 - m_space_graph_add_inverted_relation(&graph, &act_space_relation); 899 - m_space_graph_add_inverted_pose_if_not_identity(&graph, &input->xdev->tracking_origin->offset); 899 + m_relation_chain_push_inverted_relation(&chain, &act_space_relation); 900 + m_relation_chain_push_inverted_pose_if_not_identity(&chain, 901 + &input->xdev->tracking_origin->offset); 900 902 } 901 903 902 - m_space_graph_add_inverted_pose_if_not_identity(&graph, &baseSpc->pose); 903 - m_space_graph_resolve(&graph, &result); 904 + m_relation_chain_push_inverted_pose_if_not_identity(&chain, &baseSpc->pose); 905 + m_relation_chain_resolve(&chain, &result); 904 906 905 907 if (baseSpc->type == XR_REFERENCE_SPACE_TYPE_LOCAL) { 906 908 if (!global_to_local_space(sess, &result)) {
+10 -11
src/xrt/state_trackers/oxr/oxr_space.c
··· 157 157 return false; 158 158 } 159 159 160 - struct xrt_space_graph graph = {0}; 161 - m_space_graph_add_relation(&graph, rel); 162 - m_space_graph_add_inverted_pose_if_not_identity(&graph, &sess->initial_head_relation.pose); 163 - m_space_graph_resolve(&graph, rel); 160 + struct xrt_relation_chain xrc = {0}; 161 + m_relation_chain_push_relation(&xrc, rel); 162 + m_relation_chain_push_inverted_pose_if_not_identity(&xrc, &sess->initial_head_relation.pose); 163 + m_relation_chain_resolve(&xrc, rel); 164 164 165 165 return true; 166 166 } ··· 341 341 if (spc->is_reference && baseSpc->is_reference) { 342 342 return oxr_space_ref_relation(log, sess, spc->type, baseSpc->type, time, out_relation); 343 343 } 344 + /// @todo Deal with action to action by keeping a true_space that we can always go via. (poor mans space graph) 344 345 if (!spc->is_reference && !baseSpc->is_reference) { 345 - // @todo Deal with action to action by keeping a true_space that 346 - // we can always go via. Aka poor mans space graph. 347 346 // WARNING order not thought through here! 348 347 // struct xrt_pose pose1; 349 348 // struct xrt_pose pose2; ··· 442 441 443 442 // Combine space and base space poses with pure relation 444 443 struct xrt_space_relation result; 445 - struct xrt_space_graph graph = {0}; 446 - m_space_graph_add_pose_if_not_identity(&graph, &spc->pose); 447 - m_space_graph_add_relation(&graph, &pure); 448 - m_space_graph_add_inverted_pose_if_not_identity(&graph, &baseSpc->pose); 449 - m_space_graph_resolve(&graph, &result); 444 + struct xrt_relation_chain xrc = {0}; 445 + m_relation_chain_push_pose_if_not_identity(&xrc, &spc->pose); 446 + m_relation_chain_push_relation(&xrc, &pure); 447 + m_relation_chain_push_inverted_pose_if_not_identity(&xrc, &baseSpc->pose); 448 + m_relation_chain_resolve(&xrc, &result); 450 449 451 450 // Copy 452 451 union {
+12 -11
src/xrt/state_trackers/oxr/oxr_xdev.c
··· 79 79 } 80 80 81 81 void 82 - oxr_xdev_get_space_graph(struct oxr_logger *log, 83 - struct oxr_instance *inst, 84 - struct xrt_device *xdev, 85 - enum xrt_input_name name, 86 - XrTime at_time, 87 - struct xrt_space_graph *xsg) 82 + oxr_xdev_get_relation_chain(struct oxr_logger *log, 83 + struct oxr_instance *inst, 84 + struct xrt_device *xdev, 85 + enum xrt_input_name name, 86 + XrTime at_time, 87 + struct xrt_relation_chain *xrc) 88 88 { 89 89 // Convert at_time to monotonic and give to device. 90 90 uint64_t at_timestamp_ns = time_state_ts_to_monotonic_ns(inst->timekeeping, at_time); 91 91 92 - struct xrt_space_relation *rel = m_space_graph_reserve(xsg); 92 + struct xrt_space_relation *rel = m_relation_chain_reserve(xrc); 93 93 94 94 xrt_device_get_tracked_pose(xdev, name, at_timestamp_ns, rel); 95 95 96 96 // Add in the offset from the tracking system. 97 - m_space_graph_add_pose(xsg, &xdev->tracking_origin->offset); 97 + m_relation_chain_push_pose(xrc, &xdev->tracking_origin->offset); 98 98 } 99 99 100 100 void ··· 117 117 118 118 *out_value = value; 119 119 } 120 + 120 121 void 121 122 oxr_xdev_get_space_relation(struct oxr_logger *log, 122 123 struct oxr_instance *inst, ··· 125 126 XrTime at_time, 126 127 struct xrt_space_relation *out_relation) 127 128 { 128 - struct xrt_space_graph xsg = {0}; 129 - oxr_xdev_get_space_graph(log, inst, xdev, name, at_time, &xsg); 130 - m_space_graph_resolve(&xsg, out_relation); 129 + struct xrt_relation_chain xrc = {0}; 130 + oxr_xdev_get_relation_chain(log, inst, xdev, name, at_time, &xrc); 131 + m_relation_chain_resolve(&xrc, out_relation); 131 132 }
+8 -8
src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp
··· 593 593 594 594 struct xrt_pose *offset = &m_xdev->tracking_origin->offset; 595 595 596 - struct xrt_space_graph graph = {}; 597 - m_space_graph_add_relation(&graph, &rel); 598 - m_space_graph_add_pose_if_not_identity(&graph, offset); 599 - m_space_graph_resolve(&graph, &rel); 596 + struct xrt_relation_chain chain = {}; 597 + m_relation_chain_push_relation(&chain, &rel); 598 + m_relation_chain_push_pose_if_not_identity(&chain, offset); 599 + m_relation_chain_resolve(&chain, &rel); 600 600 601 601 apply_pose(&rel, &m_pose); 602 602 ··· 941 941 942 942 struct xrt_pose *offset = &m_xdev->tracking_origin->offset; 943 943 944 - struct xrt_space_graph graph = {}; 945 - m_space_graph_add_relation(&graph, &rel); 946 - m_space_graph_add_pose_if_not_identity(&graph, offset); 947 - m_space_graph_resolve(&graph, &rel); 944 + struct xrt_relation_chain chain = {}; 945 + m_relation_chain_push_relation(&chain, &rel); 946 + m_relation_chain_push_pose_if_not_identity(&chain, offset); 947 + m_relation_chain_resolve(&chain, &rel); 948 948 949 949 vr::DriverPose_t t = {}; 950 950