st/oxr: Add special xdev pose space

This commit is contained in:
Jakob Bornecrantz 2023-09-10 14:29:42 +01:00 committed by Christoph Haag
parent 158f420748
commit 18fc473735
4 changed files with 58 additions and 3 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2018-2023, Collabora, Ltd.
// Copyright 2018-2024, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
@ -71,6 +71,7 @@ oxr_ref_space_to_xr(enum oxr_space_type space_type)
case OXR_SPACE_TYPE_REFERENCE_LOCALIZATION_MAP_ML: return XR_REFERENCE_SPACE_TYPE_LOCALIZATION_MAP_ML;
case OXR_SPACE_TYPE_ACTION: return XR_REFERENCE_SPACE_TYPE_MAX_ENUM;
case OXR_SPACE_TYPE_XDEV_POSE: return XR_REFERENCE_SPACE_TYPE_MAX_ENUM;
}
return XR_REFERENCE_SPACE_TYPE_MAX_ENUM;

View file

@ -108,6 +108,7 @@ enum oxr_space_type
OXR_SPACE_TYPE_REFERENCE_LOCALIZATION_MAP_ML,
OXR_SPACE_TYPE_ACTION,
OXR_SPACE_TYPE_XDEV_POSE,
};
/*!

View file

@ -867,6 +867,18 @@ oxr_space_reference_create(struct oxr_logger *log,
const XrReferenceSpaceCreateInfo *createInfo,
struct oxr_space **out_space);
/*!
* Monado special space that always points to a specific @ref xrt_device and
* pose, useful when you want to bypass the action binding system for instance.
*/
XrResult
oxr_space_xdev_pose_create(struct oxr_logger *log,
struct oxr_session *sess,
struct xrt_device *xdev,
enum xrt_input_name name,
const struct xrt_pose *pose,
struct oxr_space **out_space);
XrResult
oxr_space_locate(
struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location);
@ -2197,7 +2209,8 @@ oxr_space_type_is_reference(enum oxr_space_type space_type)
return true;
case OXR_SPACE_TYPE_ACTION:
// Not a reference space.
case OXR_SPACE_TYPE_XDEV_POSE:
// These are not reference spaces.
return false;
}
@ -2241,6 +2254,11 @@ struct oxr_space
struct xrt_device *xdev;
enum xrt_input_name name;
} action;
struct
{
struct xrt_space *xs;
} xdev_pose;
};
/*!

View file

@ -1,4 +1,4 @@
// Copyright 2019-2023, Collabora, Ltd.
// Copyright 2019-2024, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
@ -91,6 +91,7 @@ get_xrt_space(struct oxr_logger *log, struct oxr_space *spc, struct xrt_space **
struct xrt_space *xspace = NULL;
switch (spc->space_type) {
case OXR_SPACE_TYPE_ACTION: return get_xrt_space_action(log, spc, out_xspace);
case OXR_SPACE_TYPE_XDEV_POSE: xspace = spc->xdev_pose.xs; break;
case OXR_SPACE_TYPE_REFERENCE_VIEW: xspace = spc->sess->sys->xso->semantic.view; break;
case OXR_SPACE_TYPE_REFERENCE_LOCAL: xspace = spc->sess->sys->xso->semantic.local; break;
case OXR_SPACE_TYPE_REFERENCE_LOCAL_FLOOR: xspace = spc->sess->sys->xso->semantic.local_floor; break;
@ -127,6 +128,7 @@ oxr_space_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
xrt_space_overseer_ref_space_dec(spc->sess->sys->xso, xtype);
}
xrt_space_reference(&spc->xdev_pose.xs, NULL);
xrt_space_reference(&spc->action.xs, NULL);
spc->action.xdev = NULL;
spc->action.name = 0;
@ -211,6 +213,39 @@ oxr_space_reference_create(struct oxr_logger *log,
return XR_SUCCESS;
}
XrResult
oxr_space_xdev_pose_create(struct oxr_logger *log,
struct oxr_session *sess,
struct xrt_device *xdev,
enum xrt_input_name name,
const struct xrt_pose *pose,
struct oxr_space **out_space)
{
if (!math_pose_validate(pose)) {
return oxr_error(log, XR_ERROR_POSE_INVALID, "(createInfo->offset)");
}
struct xrt_space *xspace = NULL;
xrt_result_t xret = xrt_space_overseer_create_pose_space( //
sess->sys->xso, //
xdev, //
name, //
&xspace); //
OXR_CHECK_XRET(log, sess, xret, xrt_space_overseer_create_pose_space);
struct oxr_space *spc = NULL;
OXR_ALLOCATE_HANDLE_OR_RETURN(log, spc, OXR_XR_DEBUG_SPACE, oxr_space_destroy, &sess->handle);
spc->sess = sess;
spc->pose = *pose;
spc->space_type = OXR_SPACE_TYPE_XDEV_POSE;
xrt_space_reference(&spc->xdev_pose.xs, xspace);
xrt_space_reference(&xspace, NULL);
*out_space = spc;
return XR_SUCCESS;
}
/*
*