The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Add special xdev pose space

authored by

Jakob Bornecrantz and committed by
Christoph Haag
18fc4737 158f4207

+58 -3
+2 -1
src/xrt/state_trackers/oxr/oxr_conversions.h
··· 1 - // Copyright 2018-2023, Collabora, Ltd. 1 + // Copyright 2018-2024, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 71 71 case OXR_SPACE_TYPE_REFERENCE_LOCALIZATION_MAP_ML: return XR_REFERENCE_SPACE_TYPE_LOCALIZATION_MAP_ML; 72 72 73 73 case OXR_SPACE_TYPE_ACTION: return XR_REFERENCE_SPACE_TYPE_MAX_ENUM; 74 + case OXR_SPACE_TYPE_XDEV_POSE: return XR_REFERENCE_SPACE_TYPE_MAX_ENUM; 74 75 } 75 76 76 77 return XR_REFERENCE_SPACE_TYPE_MAX_ENUM;
+1
src/xrt/state_trackers/oxr/oxr_defines.h
··· 108 108 OXR_SPACE_TYPE_REFERENCE_LOCALIZATION_MAP_ML, 109 109 110 110 OXR_SPACE_TYPE_ACTION, 111 + OXR_SPACE_TYPE_XDEV_POSE, 111 112 }; 112 113 113 114 /*!
+19 -1
src/xrt/state_trackers/oxr/oxr_objects.h
··· 867 867 const XrReferenceSpaceCreateInfo *createInfo, 868 868 struct oxr_space **out_space); 869 869 870 + /*! 871 + * Monado special space that always points to a specific @ref xrt_device and 872 + * pose, useful when you want to bypass the action binding system for instance. 873 + */ 874 + XrResult 875 + oxr_space_xdev_pose_create(struct oxr_logger *log, 876 + struct oxr_session *sess, 877 + struct xrt_device *xdev, 878 + enum xrt_input_name name, 879 + const struct xrt_pose *pose, 880 + struct oxr_space **out_space); 881 + 870 882 XrResult 871 883 oxr_space_locate( 872 884 struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location); ··· 2197 2209 return true; 2198 2210 2199 2211 case OXR_SPACE_TYPE_ACTION: 2200 - // Not a reference space. 2212 + case OXR_SPACE_TYPE_XDEV_POSE: 2213 + // These are not reference spaces. 2201 2214 return false; 2202 2215 } 2203 2216 ··· 2241 2254 struct xrt_device *xdev; 2242 2255 enum xrt_input_name name; 2243 2256 } action; 2257 + 2258 + struct 2259 + { 2260 + struct xrt_space *xs; 2261 + } xdev_pose; 2244 2262 }; 2245 2263 2246 2264 /*!
+36 -1
src/xrt/state_trackers/oxr/oxr_space.c
··· 1 - // Copyright 2019-2023, Collabora, Ltd. 1 + // Copyright 2019-2024, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 91 91 struct xrt_space *xspace = NULL; 92 92 switch (spc->space_type) { 93 93 case OXR_SPACE_TYPE_ACTION: return get_xrt_space_action(log, spc, out_xspace); 94 + case OXR_SPACE_TYPE_XDEV_POSE: xspace = spc->xdev_pose.xs; break; 94 95 case OXR_SPACE_TYPE_REFERENCE_VIEW: xspace = spc->sess->sys->xso->semantic.view; break; 95 96 case OXR_SPACE_TYPE_REFERENCE_LOCAL: xspace = spc->sess->sys->xso->semantic.local; break; 96 97 case OXR_SPACE_TYPE_REFERENCE_LOCAL_FLOOR: xspace = spc->sess->sys->xso->semantic.local_floor; break; ··· 127 128 xrt_space_overseer_ref_space_dec(spc->sess->sys->xso, xtype); 128 129 } 129 130 131 + xrt_space_reference(&spc->xdev_pose.xs, NULL); 130 132 xrt_space_reference(&spc->action.xs, NULL); 131 133 spc->action.xdev = NULL; 132 134 spc->action.name = 0; ··· 205 207 if (xtype != XRT_SPACE_REFERENCE_TYPE_INVALID) { 206 208 xrt_space_overseer_ref_space_inc(sess->sys->xso, xtype); 207 209 } 210 + 211 + *out_space = spc; 212 + 213 + return XR_SUCCESS; 214 + } 215 + 216 + XrResult 217 + oxr_space_xdev_pose_create(struct oxr_logger *log, 218 + struct oxr_session *sess, 219 + struct xrt_device *xdev, 220 + enum xrt_input_name name, 221 + const struct xrt_pose *pose, 222 + struct oxr_space **out_space) 223 + { 224 + if (!math_pose_validate(pose)) { 225 + return oxr_error(log, XR_ERROR_POSE_INVALID, "(createInfo->offset)"); 226 + } 227 + 228 + struct xrt_space *xspace = NULL; 229 + xrt_result_t xret = xrt_space_overseer_create_pose_space( // 230 + sess->sys->xso, // 231 + xdev, // 232 + name, // 233 + &xspace); // 234 + OXR_CHECK_XRET(log, sess, xret, xrt_space_overseer_create_pose_space); 235 + 236 + struct oxr_space *spc = NULL; 237 + OXR_ALLOCATE_HANDLE_OR_RETURN(log, spc, OXR_XR_DEBUG_SPACE, oxr_space_destroy, &sess->handle); 238 + spc->sess = sess; 239 + spc->pose = *pose; 240 + spc->space_type = OXR_SPACE_TYPE_XDEV_POSE; 241 + xrt_space_reference(&spc->xdev_pose.xs, xspace); 242 + xrt_space_reference(&xspace, NULL); 208 243 209 244 *out_space = spc; 210 245