Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_space.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Header defining xrt space and space overseer.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup xrt_iface
9 */
10
11#pragma once
12
13#include "xrt/xrt_defines.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#define XRT_MAX_CLIENT_SPACES 128
20struct xrt_device;
22
23/*!
24 * A space very similar to a OpenXR XrSpace but not a full one-to-one mapping,
25 * but used to power XrSpace.
26 *
27 * @see @ref xrt_space_overseer
28 * @see @ref design-spaces
29 * @ingroup xrt_iface
30 */
32{
33 /*!
34 * Reference helper.
35 */
37
38 /*!
39 * Destroy function.
40 */
41 void (*destroy)(struct xrt_space *xs);
42};
43
44/*!
45 * Update the reference counts on space(s).
46 *
47 * @param[in,out] dst Pointer to a object reference: if the object reference is
48 * non-null will decrement its counter. The reference that
49 * @p dst points to will be set to @p src.
50 * @param[in] src New object for @p dst to refer to (may be null).
51 * If non-null, will have its refcount increased.
52 * @ingroup xrt_iface
53 * @relates xrt_space
54 */
55static inline void
56xrt_space_reference(struct xrt_space **dst, struct xrt_space *src)
57{
58 struct xrt_space *old_dst = *dst;
59
60 if (old_dst == src) {
61 return;
62 }
63
64 if (src) {
65 xrt_reference_inc(&src->reference);
66 }
67
68 *dst = src;
69
70 if (old_dst) {
71 if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
72 old_dst->destroy(old_dst);
73 }
74 }
75}
76
77/*!
78 * Object that oversees and manages spaces, one created for each XR system.
79 *
80 * The space overseer is used by the state tracker to query the poses of spaces
81 * and devices in that space system. While the default implementation
82 * @ref b_space_overseer implements the spaces as a graph of relatable spaces,
83 * that is a implementation detail (the interface also lends itself to that
84 * since bases have parents). As such the graph is not exposed in this interface
85 * and spaces are technically free floating.
86 *
87 * One advantage of the free floating nature is that an overseer implementation
88 * has much greater flexibility in configuring the graph to fit the current XR
89 * system the best, it also have freedom to reconfigure the graph at runtime
90 * should that be needed. Since any potential graph isn't exposed there is no
91 * need to synchronise it across the app process and the service process.
92 *
93 * @see @ref design-spaces
94 * @ingroup xrt_iface
95 */
97{
98 struct
99 {
100 struct xrt_space *root; //!< Root space, always available
101 struct xrt_space *view; //!< View space, may be null (in very rare cases).
102 struct xrt_space *local; //!< Local space, may be null (in very rare cases).
103 struct xrt_space *local_floor; //!< Local floor space, may be null.
104 struct xrt_space *stage; //!< Stage space, may be null.
105 struct xrt_space *unbounded; //!< Unbounded space, only here for slam trackers.
106
107 /*!
108 * Semantic spaces to be mapped to OpenXR spaces.
109 */
110 } semantic;
111
112 //! Ptrs to the localspace
113 struct xrt_space *localspace[XRT_MAX_CLIENT_SPACES];
114 //! Ptrs to the localfloorspace
115 struct xrt_space *localfloorspace[XRT_MAX_CLIENT_SPACES];
116
117 /*!
118 * Create a space with a fixed offset to the parent space.
119 *
120 * @param[in] xso Owning space overseer.
121 * @param[in] parent The parent space for the new space.
122 * @param[in] offset Offset to the space.
123 * @param[out] out_space The newly created space.
124 */
126 struct xrt_space *parent,
127 const struct xrt_pose *offset,
128 struct xrt_space **out_space);
129
130 /*!
131 * Create a space that wraps the @p xdev input pose described by input
132 * @p name, implicitly make the device's tracking space the parent of
133 * the created space. The name pose_space was chosen because while most
134 * input poses are part of the device, they may also be things tracked
135 * by the device. The important part is that the space is following the
136 * pose, that it happens to be attached to device is coincidental.
137 *
138 * @param[in] xso Owning space overseer.
139 * @param[in] xdev Device to get the pose from.
140 * @param[in] name Name of the pose input.
141 * @param[out] out_space The newly created space.
142 */
144 struct xrt_device *xdev,
145 enum xrt_input_name name,
146 struct xrt_space **out_space);
147
148 /*!
149 * Locate a space in the base space.
150 *
151 * @see xrt_device::get_tracked_pose.
152 *
153 * @param[in] xso Owning space overseer.
154 * @param[in] base_space The space that we want the pose in.
155 * @param[in] base_offset Offset if any to the base space.
156 * @param[in] at_timestamp_ns At which time.
157 * @param[in] space The space to be located.
158 * @param[in] offset Offset if any to the located space.
159 * @param[out] out_relation Resulting pose.
160 */
162 struct xrt_space *base_space,
163 const struct xrt_pose *base_offset,
164 int64_t at_timestamp_ns,
165 struct xrt_space *space,
166 const struct xrt_pose *offset,
167 struct xrt_space_relation *out_relation);
168
169 /*!
170 * Locate spaces in the base space.
171 *
172 * @see xrt_device::get_tracked_pose.
173 *
174 * @param[in] xso Owning space overseer.
175 * @param[in] base_space The space that we want the pose in.
176 * @param[in] base_offset Offset if any to the base space.
177 * @param[in] at_timestamp_ns At which time.
178 * @param[in] spaces The array of pointers to spaces to be located.
179 * @param[in] space_count The number of spaces to locate.
180 * @param[in] offsets Array of offset if any to the located spaces.
181 * @param[out] out_relations Array of resulting poses.
182 */
184 struct xrt_space *base_space,
185 const struct xrt_pose *base_offset,
186 int64_t at_timestamp_ns,
187 struct xrt_space **spaces,
188 uint32_t space_count,
189 const struct xrt_pose *offsets,
190 struct xrt_space_relation *out_relations);
191
192 /*!
193 * Locate a the origin of the tracking space of a device, this is not
194 * the same as the device position. In other words, what is the position
195 * of the space that the device is in, and which it returns its poses
196 * in. Needed to use @ref xrt_device::get_view_poses and
197 * @ref xrt_device::get_hand_tracking.
198 *
199 * @see xrt_device::get_tracked_pose.
200 *
201 * @param[in] xso Owning space overseer.
202 * @param[in] base_space The space that we want the pose in.
203 * @param[in] base_offset Offset if any to the base space.
204 * @param[in] at_timestamp_ns At which time.
205 * @param[in] xdev Device to get the pose from.
206 * @param[out] out_relation Resulting pose.
207 */
209 struct xrt_space *base_space,
210 const struct xrt_pose *base_offset,
211 int64_t at_timestamp_ns,
212 struct xrt_device *xdev,
213 struct xrt_space_relation *out_relation);
214
215 /*!
216 * Increment the usage count of a reference space (aka semantic space).
217 * This lets the overseer know when different spaces are being used,
218 * allowing it to triggering a recenter if the local space is used for
219 * the first time, or stopping calculating where the stage space is if
220 * it is not used by the current application.
221 *
222 * @param[in] xso Owning space overseer.
223 * @param[in] type Which reference space is being referenced.
224 */
226
227 /*!
228 * Decrement the usage count of a reference space (aka semantic space).
229 * See @ref xrt_space_overseer::ref_space_inc.
230 *
231 * @param[in] xso Owning space overseer.
232 * @param[in] type Which reference space is being referenced.
233 */
235
236 /*!
237 * Trigger a re-center of the local and local_floor spaces, not all
238 * implementations of @ref xrt_space_overseer may support recenter. The
239 * recenter operation will normally mean that the local and local_floor
240 * will move to the where the view space currently is.
241 *
242 * @param[in] xso The space overseer.
243 */
245
246 /*!
247 * Read the offset from a tracking origin, not all
248 * implementations of @ref xrt_space_overseer may support this.
249 * Outputs are only valid if XRT_SUCCESS is returned.
250 *
251 * @param[in] xso The space overseer.
252 * @param[in] xto The tracking origin.
253 * @param[out] out_offset Pointer to an xrt_pose to write the offset to
254 */
256 struct xrt_tracking_origin *xto,
257 struct xrt_pose *out_offset);
258
259 /*!
260 * Apply an offset to a tracking origin, not all
261 * implementations of @ref xrt_space_overseer may support this.
262 *
263 * @param[in] xso The space overseer.
264 * @param[in] xto The tracking origin.
265 * @param[in] offset The offset to apply.
266 */
268 struct xrt_tracking_origin *xto,
269 const struct xrt_pose *offset);
270
271 /*!
272 * Read the offset from the given reference space, not all
273 * implementations of @ref xrt_space_overseer may support this.
274 * Outputs are only valid if XRT_SUCCESS is returned.
275 *
276 * @param[in] xso The space overseer.
277 * @param[in] type The reference space.
278 * @param[out] out_offset Pointer to write the offset to.
279 */
281 enum xrt_reference_space_type type,
282 struct xrt_pose *out_offset);
283
284 /*!
285 * Apply an offset to the given reference space, not all
286 * implementations of @ref xrt_space_overseer may support this.
287 *
288 * @param[in] xso The space overseer.
289 * @param[in] type The reference space.
290 * @param[in] offset The offset to apply.
291 */
293 enum xrt_reference_space_type type,
294 const struct xrt_pose *offset);
295
296 /*!
297 * Create a localspace and a localfloorspace.
298 *
299 * @param[in] xso Owning space overseer.
300 * @param[out] out_local_space The newly created localspace.
301 * @param[out] out_local_floor_space The newly created localfloorspace.
302 */
304 struct xrt_space **out_local_space,
305 struct xrt_space **out_local_floor_space);
306
307 /*
308 *
309 * Special inter-monado component functions.
310 *
311 */
312
313 /*!
314 * Add a tracking origin to the space overseer, giving it a space that
315 * the devices using this tracking origin are in. The exact semantic of
316 * the space is determined by the implementation of the space overseer.
317 * And may be outright rejected by the implementation.
318 *
319 * After this call completes successfully, devices using the tracking
320 * origin can be added with @ref xrt_space_overseer::add_device, and the
321 * offset of the tracking origin can be used with
322 * @ref xrt_space_overseer::get_tracking_origin_offset and
323 * @ref xrt_space_overseer::set_tracking_origin_offset if supported.
324 *
325 * The tracking origin is identified by @ref xrt_tracking_origin::id,
326 * which must be assigned. Tracking origins are never added implicitly,
327 * it must be added before any device using it. Adding a tracking origin
328 * that has already been added is a no-op and keeps its current offset.
329 * The space overseer does not take ownership of the tracking origin,
330 * the caller keeps it alive until it has been removed and all devices
331 * using it have been removed.
332 *
333 * Like @ref xrt_space_overseer::add_device this is not intended to be
334 * called by the OpenXR state tracker, but by other monado components
335 * that create tracking origins but do not own the space overseer.
336 *
337 * @param[in] xso The space overseer.
338 * @param[in] xto The tracking origin to add.
339 * @return XRT_SUCCESS if added or already present, otherwise an error
340 * code.
341 */
343
344 /*!
345 * Remove a tracking origin that was previously added with
346 * @ref xrt_space_overseer::add_tracking_origin. After this call the
347 * offset of the tracking origin can no longer be read or changed, and
348 * its devices can no longer be attached, through this space overseer.
349 *
350 * Devices using the tracking origin should be removed with
351 * @ref xrt_space_overseer::remove_device first. Devices that are still
352 * added, and any pose spaces created for them, can no longer be located
353 * and stay that way until they are removed. Adding the tracking origin
354 * again starts over from its initial offset, devices that were still
355 * added when it was removed are not revived by this and need to be
356 * removed and added again.
357 *
358 * Removing a tracking origin that was never added (or has already been
359 * removed) is a safe no-op.
360 *
361 * Like @ref xrt_space_overseer::add_tracking_origin this is not
362 * intended to be called by the OpenXR state tracker.
363 *
364 * @param[in] xso The space overseer.
365 * @param[in] xto The tracking origin to remove.
366 * @return XRT_SUCCESS if removed or not present, otherwise an error code.
367 */
369
370 /*!
371 * Add a new device to be tracked by the space overseer. The exact
372 * semantic of the space is determined by the implementation of the
373 * space overseer. And may be outright rejected by the implementation.
374 *
375 * After this call completes successfully, the device can be passed
376 * into the @ref xrt_space_overseer::locate_device function, but may
377 * not be locatable immediately.
378 *
379 * The tracking origin of the device must have been added with
380 * @ref xrt_space_overseer::add_tracking_origin before the device.
381 *
382 * This function is not intended to be called by the OpenXR state
383 * tracker, but by other monado components that need to add devices
384 * but does not own the space overseer. Components like the fixer
385 * uppers or for push devices.
386 *
387 * @param[in] xso The space overseer.
388 * @param[in] xdev The device to be tracked.
389 * @return XRT_SUCCESS if added, XRT_ERROR_TRACKING_ORIGIN_NOT_ADDED if
390 * the tracking origin of the device has not been added,
391 * otherwise an error code.
392 */
394
395 /*!
396 * Remove a device that was previously added with
397 * @ref xrt_space_overseer::add_device. After this call the device can no
398 * longer be located through this space overseer and any pose spaces that
399 * were created for it become invalid.
400 *
401 * Removing a device that was never added (or has already been removed)
402 * is a safe no-op.
403 *
404 * Like @ref xrt_space_overseer::add_device this is not intended to be
405 * called by the OpenXR state tracker, but by other monado components
406 * that add devices but do not own the space overseer, for instance to
407 * support hotplugging.
408 *
409 * @param[in] xso The space overseer.
410 * @param[in] xdev The device to stop tracking.
411 * @return XRT_SUCCESS if removed or not present, otherwise an error code.
412 */
414
415 /*!
416 * Attach a device to a different space then it was associated with
417 * originally, the space overseer might not support this operation.
418 *
419 * For some space overseer implementations this operation requires
420 * that the device has the tracking origin type of
421 * @ref XRT_TRACKING_TYPE_ATTACHABLE. Which space that becomes the
422 * parent space of the device when @p space is NULL is undefined,
423 * and the device might become un-trackable.
424 *
425 * @param[in] xso Owning space overseer.
426 * @param[in] xdev Device to attach.
427 * @param[in] space Space to attach the device to, may be NULL.
428 *
429 * @return XRT_SUCCESS on success.
430 * @return XRT_ERROR_DEVICE_NOT_ATTACHABLE if the device does not have
431 * the XRT_TRACKING_TYPE_ATTACHABLE tracking origin type.
432 */
433 xrt_result_t (*attach_device)(struct xrt_space_overseer *xso, struct xrt_device *xdev, struct xrt_space *space);
434
435
436 /*
437 *
438 * Destroy function always comes last.
439 *
440 */
441
442 /*!
443 * Destroy function.
444 *
445 * @param xso The space overseer.
446 */
447 void (*destroy)(struct xrt_space_overseer *xs);
448};
449
450/*!
451 * @copydoc xrt_space_overseer::create_offset_space
452 *
453 * Helper for calling through the function pointer.
454 *
455 * @public @memberof xrt_space_overseer
456 */
457XRT_NONNULL_ALL static inline xrt_result_t
459 struct xrt_space *parent,
460 const struct xrt_pose *offset,
461 struct xrt_space **out_space)
462{
463 return xso->create_offset_space(xso, parent, offset, out_space);
464}
465
466/*!
467 * @copydoc xrt_space_overseer::create_pose_space
468 *
469 * Helper for calling through the function pointer.
470 *
471 * @public @memberof xrt_space_overseer
472 */
473XRT_NONNULL_ALL static inline xrt_result_t
475 struct xrt_device *xdev,
476 enum xrt_input_name name,
477 struct xrt_space **out_space)
478{
479 return xso->create_pose_space(xso, xdev, name, out_space);
480}
481
482/*!
483 * @copydoc xrt_space_overseer::locate_space
484 *
485 * Helper for calling through the function pointer.
486 *
487 * @public @memberof xrt_space_overseer
488 */
489XRT_NONNULL_ALL static inline xrt_result_t
491 struct xrt_space *base_space,
492 const struct xrt_pose *base_offset,
493 int64_t at_timestamp_ns,
494 struct xrt_space *space,
495 const struct xrt_pose *offset,
496 struct xrt_space_relation *out_relation)
497{
498 return xso->locate_space(xso, base_space, base_offset, at_timestamp_ns, space, offset, out_relation);
499}
500
501/*!
502 * @copydoc xrt_space_overseer::locate_spaces
503 *
504 * Helper for calling through the function pointer.
505 *
506 * @public @memberof xrt_space_overseer
507 */
508XRT_NONNULL_ALL static inline xrt_result_t
510 struct xrt_space *base_space,
511 const struct xrt_pose *base_offset,
512 int64_t at_timestamp_ns,
513 struct xrt_space **spaces,
514 uint32_t space_count,
515 const struct xrt_pose *offsets,
516 struct xrt_space_relation *out_relations)
517{
518 return xso->locate_spaces(xso, base_space, base_offset, at_timestamp_ns, spaces, space_count, offsets,
519 out_relations);
520}
521
522/*!
523 * @copydoc xrt_space_overseer::locate_device
524 *
525 * Helper for calling through the function pointer.
526 *
527 * @public @memberof xrt_space_overseer
528 */
529XRT_NONNULL_ALL static inline xrt_result_t
531 struct xrt_space *base_space,
532 const struct xrt_pose *base_offset,
533 int64_t at_timestamp_ns,
534 struct xrt_device *xdev,
535 struct xrt_space_relation *out_relation)
536{
537 return xso->locate_device(xso, base_space, base_offset, at_timestamp_ns, xdev, out_relation);
538}
539
540/*!
541 * @copydoc xrt_space_overseer::ref_space_inc
542 *
543 * Helper for calling through the function pointer.
544 *
545 * @public @memberof xrt_space_overseer
546 */
547XRT_NONNULL_ALL static inline xrt_result_t
549{
550 return xso->ref_space_inc(xso, type);
551}
552
553/*!
554 * @copydoc xrt_space_overseer::ref_space_dec
555 *
556 * Helper for calling through the function pointer.
557 *
558 * @public @memberof xrt_space_overseer
559 */
560XRT_NONNULL_ALL static inline xrt_result_t
562{
563 return xso->ref_space_dec(xso, type);
564}
565
566/*!
567 * @copydoc xrt_space_overseer::recenter_local_spaces
568 *
569 * Helper for calling through the function pointer.
570 *
571 * @public @memberof xrt_space_overseer
572 */
573XRT_NONNULL_ALL static inline xrt_result_t
578
579/*!
580 * @copydoc xrt_space_overseer::get_tracking_origin_offset
581 *
582 * Helper for calling through the function pointer.
583 *
584 * @public @memberof xrt_space_overseer
585 */
586XRT_NONNULL_ALL static inline xrt_result_t
588 struct xrt_tracking_origin *xto,
589 struct xrt_pose *out_offset)
590{
591 return xso->get_tracking_origin_offset(xso, xto, out_offset);
592}
593
594/*!
595 * @copydoc xrt_space_overseer::set_tracking_origin_offset
596 *
597 * Helper for calling through the function pointer.
598 *
599 * @public @memberof xrt_space_overseer
600 */
601XRT_NONNULL_ALL static inline xrt_result_t
603 struct xrt_tracking_origin *xto,
604 const struct xrt_pose *offset)
605{
606 return xso->set_tracking_origin_offset(xso, xto, offset);
607}
608
609/*!
610 * @copydoc xrt_space_overseer::get_reference_space_offset
611 *
612 * Helper for calling through the function pointer.
613 *
614 * @public @memberof xrt_space_overseer
615 */
616XRT_NONNULL_ALL static inline xrt_result_t
618 enum xrt_reference_space_type type,
619 struct xrt_pose *out_offset)
620{
621 return xso->get_reference_space_offset(xso, type, out_offset);
622}
623
624/*!
625 * @copydoc xrt_space_overseer::set_reference_space_offset
626 *
627 * Helper for calling through the function pointer.
628 *
629 * @public @memberof xrt_space_overseer
630 */
631XRT_NONNULL_ALL static inline xrt_result_t
633 enum xrt_reference_space_type type,
634 const struct xrt_pose *offset)
635{
636 return xso->set_reference_space_offset(xso, type, offset);
637}
638
639/*!
640 * @copydoc xrt_space_overseer::create_local_space
641 *
642 * Helper for calling through the function pointer.
643 *
644 * @public @memberof xrt_space_overseer
645 */
646XRT_NONNULL_ALL static inline xrt_result_t
648 struct xrt_space **out_local_space,
649 struct xrt_space **out_local_floor_space)
650{
651 return xso->create_local_space(xso, out_local_space, out_local_floor_space);
652}
653
654/*!
655 * @copydoc xrt_space_overseer::add_tracking_origin
656 *
657 * Helper for calling through the function pointer.
658 *
659 * @public @memberof xrt_space_overseer
660 */
661XRT_NONNULL_ALL static inline xrt_result_t
663{
664 return xso->add_tracking_origin(xso, xto);
665}
666
667/*!
668 * @copydoc xrt_space_overseer::remove_tracking_origin
669 *
670 * Helper for calling through the function pointer.
671 *
672 * @public @memberof xrt_space_overseer
673 */
674XRT_NONNULL_ALL static inline xrt_result_t
679
680/*!
681 * @copydoc xrt_space_overseer::add_device
682 *
683 * Helper for calling through the function pointer.
684 *
685 * @public @memberof xrt_space_overseer
686 */
687XRT_NONNULL_ALL static inline xrt_result_t
689{
690 return xso->add_device(xso, xdev);
691}
692
693/*!
694 * @copydoc xrt_space_overseer::remove_device
695 *
696 * Helper for calling through the function pointer.
697 *
698 * @public @memberof xrt_space_overseer
699 */
700XRT_NONNULL_ALL static inline xrt_result_t
702{
703 return xso->remove_device(xso, xdev);
704}
705
706/*!
707 * @copydoc xrt_space_overseer::attach_device
708 *
709 * Helper for calling through the function pointer.
710 *
711 * @public @memberof xrt_space_overseer
712 */
713XRT_NONNULL_ALL static inline xrt_result_t
715{
716 return xso->attach_device(xso, xdev, space);
717}
718
719/*!
720 * Helper for calling through the function pointer: does a null check and sets
721 * xc_ptr to null if freed.
722 *
723 * @see xrt_space_overseer::destroy
724 * @public @memberof xrt_space_overseer
725 */
726static inline void
728{
729 struct xrt_space_overseer *xso = *xso_ptr;
730 if (xso == NULL) {
731 return;
732 }
733
734 xso->destroy(xso);
735 *xso_ptr = NULL;
736}
737
738
739#ifdef __cplusplus
740}
741#endif
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition xrt_defines.h:1031
enum xrt_result xrt_result_t
Result type used across Monado.
xrt_reference_space_type
Type of a OpenXR mapped reference space, maps to the semantic spaces on the xrt_space_overseer struct...
Definition xrt_defines.h:668
static void xrt_space_reference(struct xrt_space **dst, struct xrt_space *src)
Update the reference counts on space(s).
Definition xrt_space.h:56
A single HMD or input device.
Definition xrt_device.h:345
A pose composed of a position and orientation.
Definition xrt_defines.h:535
A base class for reference counted objects.
Definition xrt_defines.h:99
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
xrt_result_t(* get_reference_space_offset)(struct xrt_space_overseer *xso, enum xrt_reference_space_type type, struct xrt_pose *out_offset)
Read the offset from the given reference space, not all implementations of xrt_space_overseer may sup...
Definition xrt_space.h:280
struct xrt_space * unbounded
Unbounded space, only here for slam trackers.
Definition xrt_space.h:105
struct xrt_space * localspace[128]
Ptrs to the localspace.
Definition xrt_space.h:113
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_locate_spaces(struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_space **spaces, uint32_t space_count, const struct xrt_pose *offsets, struct xrt_space_relation *out_relations)
Locate spaces in the base space.
Definition xrt_space.h:509
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_create_offset_space(struct xrt_space_overseer *xso, struct xrt_space *parent, const struct xrt_pose *offset, struct xrt_space **out_space)
Create a space with a fixed offset to the parent space.
Definition xrt_space.h:458
xrt_result_t(* get_tracking_origin_offset)(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto, struct xrt_pose *out_offset)
Read the offset from a tracking origin, not all implementations of xrt_space_overseer may support thi...
Definition xrt_space.h:255
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_remove_tracking_origin(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto)
Remove a tracking origin that was previously added with xrt_space_overseer::add_tracking_origin.
Definition xrt_space.h:675
xrt_result_t(* remove_device)(struct xrt_space_overseer *xso, struct xrt_device *xdev)
Remove a device that was previously added with xrt_space_overseer::add_device.
Definition xrt_space.h:413
void(* destroy)(struct xrt_space_overseer *xs)
Destroy function.
Definition xrt_space.h:447
xrt_result_t(* add_tracking_origin)(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto)
Add a tracking origin to the space overseer, giving it a space that the devices using this tracking o...
Definition xrt_space.h:342
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_recenter_local_spaces(struct xrt_space_overseer *xso)
Trigger a re-center of the local and local_floor spaces, not all implementations of xrt_space_oversee...
Definition xrt_space.h:574
xrt_result_t(* ref_space_dec)(struct xrt_space_overseer *xso, enum xrt_reference_space_type type)
Decrement the usage count of a reference space (aka semantic space).
Definition xrt_space.h:234
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_create_local_space(struct xrt_space_overseer *xso, struct xrt_space **out_local_space, struct xrt_space **out_local_floor_space)
Create a localspace and a localfloorspace.
Definition xrt_space.h:647
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_get_tracking_origin_offset(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto, struct xrt_pose *out_offset)
Read the offset from a tracking origin, not all implementations of xrt_space_overseer may support thi...
Definition xrt_space.h:587
struct xrt_space * local
Local space, may be null (in very rare cases).
Definition xrt_space.h:102
struct xrt_space * local_floor
Local floor space, may be null.
Definition xrt_space.h:103
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_set_reference_space_offset(struct xrt_space_overseer *xso, enum xrt_reference_space_type type, const struct xrt_pose *offset)
Apply an offset to the given reference space, not all implementations of xrt_space_overseer may suppo...
Definition xrt_space.h:632
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_ref_space_inc(struct xrt_space_overseer *xso, enum xrt_reference_space_type type)
Increment the usage count of a reference space (aka semantic space).
Definition xrt_space.h:548
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_ref_space_dec(struct xrt_space_overseer *xso, enum xrt_reference_space_type type)
Decrement the usage count of a reference space (aka semantic space).
Definition xrt_space.h:561
xrt_result_t(* create_offset_space)(struct xrt_space_overseer *xso, struct xrt_space *parent, const struct xrt_pose *offset, struct xrt_space **out_space)
Create a space with a fixed offset to the parent space.
Definition xrt_space.h:125
struct xrt_space * view
View space, may be null (in very rare cases).
Definition xrt_space.h:101
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_add_device(struct xrt_space_overseer *xso, struct xrt_device *xdev)
Add a new device to be tracked by the space overseer.
Definition xrt_space.h:688
xrt_result_t(* locate_spaces)(struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_space **spaces, uint32_t space_count, const struct xrt_pose *offsets, struct xrt_space_relation *out_relations)
Locate spaces in the base space.
Definition xrt_space.h:183
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_attach_device(struct xrt_space_overseer *xso, struct xrt_device *xdev, struct xrt_space *space)
Attach a device to a different space then it was associated with originally, the space overseer might...
Definition xrt_space.h:714
xrt_result_t(* set_tracking_origin_offset)(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto, const struct xrt_pose *offset)
Apply an offset to a tracking origin, not all implementations of xrt_space_overseer may support this.
Definition xrt_space.h:267
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_create_pose_space(struct xrt_space_overseer *xso, struct xrt_device *xdev, enum xrt_input_name name, struct xrt_space **out_space)
Create a space that wraps the xdev input pose described by input name, implicitly make the device's t...
Definition xrt_space.h:474
struct xrt_space * stage
Stage space, may be null.
Definition xrt_space.h:104
static void xrt_space_overseer_destroy(struct xrt_space_overseer **xso_ptr)
Helper for calling through the function pointer: does a null check and sets xc_ptr to null if freed.
Definition xrt_space.h:727
xrt_result_t(* locate_space)(struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_space *space, const struct xrt_pose *offset, struct xrt_space_relation *out_relation)
Locate a space in the base space.
Definition xrt_space.h:161
xrt_result_t(* set_reference_space_offset)(struct xrt_space_overseer *xso, enum xrt_reference_space_type type, const struct xrt_pose *offset)
Apply an offset to the given reference space, not all implementations of xrt_space_overseer may suppo...
Definition xrt_space.h:292
xrt_result_t(* add_device)(struct xrt_space_overseer *xso, struct xrt_device *xdev)
Add a new device to be tracked by the space overseer.
Definition xrt_space.h:393
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_locate_device(struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_device *xdev, struct xrt_space_relation *out_relation)
Locate a the origin of the tracking space of a device, this is not the same as the device position.
Definition xrt_space.h:530
xrt_result_t(* create_local_space)(struct xrt_space_overseer *xso, struct xrt_space **out_local_space, struct xrt_space **out_local_floor_space)
Create a localspace and a localfloorspace.
Definition xrt_space.h:303
xrt_result_t(* remove_tracking_origin)(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto)
Remove a tracking origin that was previously added with xrt_space_overseer::add_tracking_origin.
Definition xrt_space.h:368
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_add_tracking_origin(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto)
Add a tracking origin to the space overseer, giving it a space that the devices using this tracking o...
Definition xrt_space.h:662
struct xrt_space * root
Root space, always available.
Definition xrt_space.h:100
xrt_result_t(* locate_device)(struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_device *xdev, struct xrt_space_relation *out_relation)
Locate a the origin of the tracking space of a device, this is not the same as the device position.
Definition xrt_space.h:208
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_get_reference_space_offset(struct xrt_space_overseer *xso, enum xrt_reference_space_type type, struct xrt_pose *out_offset)
Read the offset from the given reference space, not all implementations of xrt_space_overseer may sup...
Definition xrt_space.h:617
xrt_result_t(* create_pose_space)(struct xrt_space_overseer *xso, struct xrt_device *xdev, enum xrt_input_name name, struct xrt_space **out_space)
Create a space that wraps the xdev input pose described by input name, implicitly make the device's t...
Definition xrt_space.h:143
xrt_result_t(* attach_device)(struct xrt_space_overseer *xso, struct xrt_device *xdev, struct xrt_space *space)
Attach a device to a different space then it was associated with originally, the space overseer might...
Definition xrt_space.h:433
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_remove_device(struct xrt_space_overseer *xso, struct xrt_device *xdev)
Remove a device that was previously added with xrt_space_overseer::add_device.
Definition xrt_space.h:701
xrt_result_t(* recenter_local_spaces)(struct xrt_space_overseer *xso)
Trigger a re-center of the local and local_floor spaces, not all implementations of xrt_space_oversee...
Definition xrt_space.h:244
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_set_tracking_origin_offset(struct xrt_space_overseer *xso, struct xrt_tracking_origin *xto, const struct xrt_pose *offset)
Apply an offset to a tracking origin, not all implementations of xrt_space_overseer may support this.
Definition xrt_space.h:602
struct xrt_space * localfloorspace[128]
Ptrs to the localfloorspace.
Definition xrt_space.h:115
static XRT_NONNULL_ALL xrt_result_t xrt_space_overseer_locate_space(struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_space *space, const struct xrt_pose *offset, struct xrt_space_relation *out_relation)
Locate a space in the base space.
Definition xrt_space.h:490
xrt_result_t(* ref_space_inc)(struct xrt_space_overseer *xso, enum xrt_reference_space_type type)
Increment the usage count of a reference space (aka semantic space).
Definition xrt_space.h:225
A relation with two spaces, includes velocity and acceleration.
Definition xrt_defines.h:726
A space very similar to a OpenXR XrSpace but not a full one-to-one mapping, but used to power XrSpace...
Definition xrt_space.h:32
struct xrt_reference reference
Reference helper.
Definition xrt_space.h:36
void(* destroy)(struct xrt_space *xs)
Destroy function.
Definition xrt_space.h:41
A tracking system or device origin.
Definition xrt_tracking.h:115
Common defines and enums for XRT.