···4949DEBUG_GET_ONCE_BOOL_OPTION(debug_bindings, "OXR_DEBUG_BINDINGS", false)
5050DEBUG_GET_ONCE_BOOL_OPTION(lifecycle_verbose, "OXR_LIFECYCLE_VERBOSE", false)
51515252-DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_x, "OXR_TRACKING_ORIGIN_OFFSET_X", 0.0f)
5353-DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_y, "OXR_TRACKING_ORIGIN_OFFSET_Y", 0.0f)
5454-DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_z, "OXR_TRACKING_ORIGIN_OFFSET_Z", 0.0f)
55525653static XrResult
5754oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
···301298 oxr_instance_destroy(log, &inst->handle);
302299 return ret;
303300 }
304304-305305- struct xrt_vec3 global_tracking_origin_offset = {debug_get_float_option_tracking_origin_offset_x(),
306306- debug_get_float_option_tracking_origin_offset_y(),
307307- debug_get_float_option_tracking_origin_offset_z()};
308308-309309- u_builder_setup_tracking_origins(dev, GET_XDEV_BY_ROLE(sys, left), GET_XDEV_BY_ROLE(sys, right),
310310- &global_tracking_origin_offset);
311301312302 // Sets the enabled extensions, this is where we should do any extra validation.
313303 inst->extensions = *extensions;
+26-79
src/xrt/state_trackers/oxr/oxr_objects.h
···764764 const XrReferenceSpaceCreateInfo *createInfo,
765765 struct oxr_space **out_space);
766766767767-/*!
768768- * Transforms a relation given in pure global space into the oxr_space @p spc.
769769- * If @p apply_space_pose is true, the pose offset of @p spc will be included in @p out_relation.
770770- */
771771-XRT_CHECK_RESULT bool
772772-oxr_space_pure_relation_in_space(struct oxr_logger *log,
773773- XrTime time,
774774- struct xrt_space_relation *relation,
775775- struct oxr_space *spc,
776776- bool apply_space_pose,
777777- struct xrt_space_relation *out_relation);
767767+XrResult
768768+oxr_space_locate(
769769+ struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location);
778770779771/*!
780780- * Transforms a pose given in pure global space into a relation in the oxr_space @p spc.
781781- * If @p apply_space_pose is true, the pose offset of @p spc will be included in @p out_relation.
782782- */
783783-XRT_CHECK_RESULT bool
784784-oxr_space_pure_pose_in_space(struct oxr_logger *log,
785785- XrTime time,
786786- struct xrt_pose *pose,
787787- struct oxr_space *spc,
788788- bool apply_space_pose,
789789- struct xrt_space_relation *out_relation);
790790-791791-/*!
792792- * Transforms a relation in an given oxr_space @p spc into pure global space, taking the pose offset of @p spc into
793793- * account.
794794- */
795795-XRT_CHECK_RESULT bool
796796-oxr_space_pure_relation_from_space(struct oxr_logger *log,
797797- XrTime time,
798798- struct xrt_space_relation *relation,
799799- struct oxr_space *spc,
800800- struct xrt_space_relation *out_relation);
801801-802802-/*!
803803- * Transforms a posen in a given oxr_space @p spc into a relation in "pure" global space, taking the pose offset of @p
804804- * spc into account.
805805- */
806806-XRT_CHECK_RESULT bool
807807-oxr_space_pure_pose_from_space(struct oxr_logger *log,
808808- XrTime time,
809809- struct xrt_pose *pose,
810810- struct oxr_space *spc,
811811- struct xrt_space_relation *out_relation);
812812-813813-/*!
814814- * Returns the pure relation in global space of an oxr_space, meaning the tracking_origin offsets are already applied
815815- * and sets @p out_xdev to the device the space is associated with.
772772+ * Locate the @ref xrt_device in the given base space, useful for implementing
773773+ * hand tracking location look ups and the like.
774774+ *
775775+ * @param log Logging struct.
776776+ * @param xdev Device to locate in the base space.
777777+ * @param baseSpc Base space where the device is to be located.
778778+ * @param[in] time Time in OpenXR domain.
779779+ * @param[out] out_relation Returns T_base_xdev, aka xdev in base space.
816780 *
817817- * @todo: This function currently assumes all reference spaces are associated with the HMD.
781781+ * @return Any errors, XR_SUCCESS, pose might not be valid on XR_SUCCESS.
818782 */
819819-XRT_CHECK_RESULT bool
820820-oxr_space_get_pure_relation(struct oxr_logger *log,
821821- struct oxr_space *spc,
822822- XrTime time,
823823- struct xrt_space_relation *out_relation);
824824-825825-XrResult
826826-oxr_space_locate(
827827- struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location);
828828-829829-XRT_CHECK_RESULT bool
830830-is_local_space_set_up(struct oxr_session *sess);
831831-832832-XRT_CHECK_RESULT bool
833833-global_to_local_space(struct oxr_logger *log, struct oxr_session *sess, XrTime time, struct xrt_space_relation *rel);
783783+XRT_CHECK_RESULT XrResult
784784+oxr_space_locate_device(struct oxr_logger *log,
785785+ struct xrt_device *xdev,
786786+ struct oxr_space *baseSpc,
787787+ XrTime time,
788788+ struct xrt_space_relation *out_relation);
834789835790836791/*
···996951bool
997952oxr_xdev_find_output(struct xrt_device *xdev, enum xrt_output_name name, struct xrt_output **out_output);
998953999999-void
10001000-oxr_xdev_get_relation_chain(struct oxr_logger *log,
10011001- struct oxr_instance *inst,
10021002- struct xrt_device *xdev,
10031003- enum xrt_input_name name,
10041004- XrTime at_time,
10051005- struct xrt_relation_chain *xrc);
10061006-10071007-void
10081008-oxr_xdev_get_space_relation(struct oxr_logger *log,
10091009- struct oxr_instance *inst,
10101010- struct xrt_device *xdev,
10111011- enum xrt_input_name name,
10121012- XrTime at_time,
10131013- struct xrt_space_relation *out_relation);
10141014-1015954/*!
1016955 * Returns the hand tracking value of the named input from the device.
1017956 * Does NOT apply tracking origin offset to each joint.
···1023962 enum xrt_input_name name,
1024963 XrTime at_time,
1025964 struct xrt_hand_joint_set *out_value);
965965+10269661027967/*
1028968 *
···1995193519961936 //! Which sub action path is this?
19971937 struct oxr_subaction_paths subaction_paths;
19381938+19391939+ struct
19401940+ {
19411941+ struct xrt_space *xs;
19421942+ struct xrt_device *xdev;
19431943+ enum xrt_input_name name;
19441944+ } action;
19981945};
1999194620001947/*!
+45-41
src/xrt/state_trackers/oxr/oxr_session.c
···343343 const uint64_t xdisplay_time =
344344 time_state_ts_to_monotonic_ns(sess->sys->inst->timekeeping, viewLocateInfo->displayTime);
345345346346- struct xrt_space_relation head_relation = XRT_SPACE_RELATION_ZERO;
346346+ // The head pose as in the xdev's space, aka XRT_INPUT_GENERIC_HEAD_POSE.
347347+ struct xrt_space_relation T_xdev_head = XRT_SPACE_RELATION_ZERO;
347348 struct xrt_fov fovs[2] = {0};
348349 struct xrt_pose poses[2] = {0};
349350···352353 &default_eye_relation, //
353354 xdisplay_time, //
354355 2, //
355355- &head_relation, //
356356+ &T_xdev_head, //
356357 fovs, //
357358 poses);
358359359359-360360- struct xrt_space_relation pure_head_relation;
361361-362362- // head_relation is in xdev space. Bring it into pure global space by applying tracking origin offset.
363363- struct xrt_relation_chain xrc = {0};
364364- m_relation_chain_push_relation(&xrc, &head_relation);
365365- m_relation_chain_push_pose_if_not_identity(&xrc, &xdev->tracking_origin->offset);
366366- m_relation_chain_resolve(&xrc, &pure_head_relation);
367367-368368- // Clear here and filled in loop.
369369- viewState->viewStateFlags = 0;
370370-371371- struct xrt_space_relation head_relation_in_base_space;
372372- if (!oxr_space_pure_relation_in_space(log, viewLocateInfo->displayTime, &pure_head_relation, baseSpc, true,
373373- &head_relation_in_base_space)) {
374374- for (uint32_t i = 0; i < view_count; i++) {
375375- OXR_XRT_POSE_TO_XRPOSEF(XRT_POSE_IDENTITY, views[i].pose);
376376- }
377377-360360+ // The xdev pose in the base space.
361361+ struct xrt_space_relation T_base_xdev = XRT_SPACE_RELATION_ZERO;
362362+ XrResult ret = oxr_space_locate_device( //
363363+ log, //
364364+ xdev, //
365365+ baseSpc, //
366366+ viewLocateInfo->displayTime, //
367367+ &T_base_xdev); //
368368+ if (ret != XR_SUCCESS || T_base_xdev.relation_flags == 0) {
378369 if (print) {
379370 oxr_slog(&slog, "\n\tReturning invalid poses");
380371 oxr_log_slog(log, &slog);
381372 } else {
382373 oxr_slog_cancel(&slog);
383374 }
384384-385385- return XR_SUCCESS;
375375+ return ret;
386376 }
387377378378+ struct xrt_space_relation T_base_head;
379379+ struct xrt_relation_chain xrc = {0};
380380+ m_relation_chain_push_relation(&xrc, &T_xdev_head);
381381+ m_relation_chain_push_relation(&xrc, &T_base_xdev);
382382+ m_relation_chain_resolve(&xrc, &T_base_head);
383383+388384 if (print) {
389385 for (uint32_t i = 0; i < view_count; i++) {
390386 char tmp[32];
···392388 oxr_pp_fov_indented_as_object(&slog, &fovs[i], tmp);
393389 oxr_pp_pose_indented_as_object(&slog, &poses[i], tmp);
394390 }
395395- oxr_pp_relation_indented(&slog, &head_relation, "xdev.head_relation");
396396- oxr_pp_relation_indented(&slog, &head_relation_in_base_space, "head_relation_in_base_space");
391391+ oxr_pp_relation_indented(&slog, &T_xdev_head, "T_xdev_head");
392392+ oxr_pp_relation_indented(&slog, &T_base_xdev, "T_base_xdev");
397393 }
398394399395 for (uint32_t i = 0; i < view_count; i++) {
···407403 struct xrt_space_relation result = {0};
408404 struct xrt_relation_chain xrc = {0};
409405 m_relation_chain_push_pose_if_not_identity(&xrc, &view_pose);
410410- m_relation_chain_push_relation(&xrc, &head_relation_in_base_space);
406406+ m_relation_chain_push_relation(&xrc, &T_base_head);
411407 m_relation_chain_resolve(&xrc, &result);
412408 OXR_XRT_POSE_TO_XRPOSEF(result.pose, views[i].pose);
413409···942938943939 oxr_xdev_get_hand_tracking_at(log, sess->sys->inst, xdev, name, at_time, &value);
944940945945- struct xrt_space_relation pure_hand_relation = value.hand_pose;
946946- struct xrt_relation_chain xrc = {0};
947947- m_relation_chain_push_relation(&xrc, &pure_hand_relation);
948948- m_relation_chain_push_pose_if_not_identity(&xrc, &xdev->tracking_origin->offset);
949949- m_relation_chain_resolve(&xrc, &pure_hand_relation);
941941+ // The hand pose is returned in the xdev's space.
942942+ struct xrt_space_relation T_xdev_hand = value.hand_pose;
950943951951- struct xrt_space_relation hand_pose_in_base_space;
952952- bool has_hand_pose_in_base_sapce = oxr_space_pure_relation_in_space( //
953953- log, //
954954- at_time, //
955955- &pure_hand_relation, //
956956- baseSpc, //
957957- true, //
958958- &hand_pose_in_base_space); //
944944+ // Get the xdev's pose in the base space.
945945+ struct xrt_space_relation T_base_xdev = XRT_SPACE_RELATION_ZERO;
946946+947947+ XrResult ret = oxr_space_locate_device(log, xdev, baseSpc, at_time, &T_base_xdev);
948948+ if (ret != XR_SUCCESS) {
949949+ // Error printed logged oxr_space_locate_device
950950+ return ret;
951951+ }
952952+ if (T_base_xdev.relation_flags == 0) {
953953+ locations->isActive = false;
954954+ return XR_SUCCESS;
955955+ }
956956+957957+ // Get the hands pose in the base space.
958958+ struct xrt_space_relation T_base_hand;
959959+ struct xrt_relation_chain xrc = {0};
960960+ m_relation_chain_push_relation(&xrc, &T_xdev_hand);
961961+ m_relation_chain_push_relation(&xrc, &T_base_xdev);
962962+ m_relation_chain_resolve(&xrc, &T_base_hand);
959963960964 // Can we not relate to this space or did we not get values?
961961- if (!has_hand_pose_in_base_sapce || !value.is_active) {
965965+ if (T_base_hand.relation_flags == 0 || !value.is_active) {
962966 locations->isActive = false;
963967964968 // Loop over all joints and zero flags.
···986990 struct xrt_space_relation result;
987991 struct xrt_relation_chain chain = {0};
988992 m_relation_chain_push_relation(&chain, &r);
989989- m_relation_chain_push_relation(&chain, &hand_pose_in_base_space);
993993+ m_relation_chain_push_relation(&chain, &T_base_hand);
990994 m_relation_chain_resolve(&chain, &result);
991995992996 xrt_to_xr_pose(&result.pose, &locations->jointLocations[i].pose);