xrt: Move tracking origin setup code to u_device

This commit is contained in:
Christoph Haag 2020-11-09 00:30:30 +01:00
parent c60b7412e5
commit 9d894ab5ff
4 changed files with 42 additions and 30 deletions

View file

@ -359,3 +359,30 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs,
}
}
}
void
u_device_setup_tracking_origins(struct xrt_device *head,
struct xrt_device *left,
struct xrt_device *right)
{
if (head->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
// "nominal height" 1.6m
head->tracking_origin->offset.position.x = 0.0f;
head->tracking_origin->offset.position.y = 1.6f;
head->tracking_origin->offset.position.z = 0.0f;
}
if (left != NULL &&
left->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
left->tracking_origin->offset.position.x = -0.2f;
left->tracking_origin->offset.position.y = 1.3f;
left->tracking_origin->offset.position.z = -0.5f;
}
if (right != NULL &&
right->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
right->tracking_origin->offset.position.x = 0.2f;
right->tracking_origin->offset.position.y = 1.3f;
right->tracking_origin->offset.position.z = -0.5f;
}
}

View file

@ -112,6 +112,16 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs,
int *left,
int *right);
/*!
* Helper function to assign head, left hand and right hand roles.
*
* @ingroup aux_util
*/
void
u_device_setup_tracking_origins(struct xrt_device *head,
struct xrt_device *left,
struct xrt_device *right);
#ifdef __cplusplus
}
#endif

View file

@ -255,6 +255,9 @@ oxr_instance_create(struct oxr_logger *log,
return ret;
}
u_device_setup_tracking_origins(dev, GET_XDEV_BY_ROLE(sys, left),
GET_XDEV_BY_ROLE(sys, right));
const float left_override = debug_get_float_option_lfov_left();
if (left_override != 0.0f) {
printf(

View file

@ -102,36 +102,6 @@ oxr_system_fill_in(struct oxr_logger *log,
XrSystemId systemId,
struct oxr_system *sys)
{
struct xrt_device *head = GET_XDEV_BY_ROLE(sys, head);
struct xrt_device *left = GET_XDEV_BY_ROLE(sys, left);
struct xrt_device *right = GET_XDEV_BY_ROLE(sys, right);
if (head == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to probe device");
}
if (head->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
// "nominal height" 1.6m
head->tracking_origin->offset.position.x = 0.0f;
head->tracking_origin->offset.position.y = 1.6f;
head->tracking_origin->offset.position.z = 0.0f;
}
if (left != NULL &&
left->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
left->tracking_origin->offset.position.x = -0.2f;
left->tracking_origin->offset.position.y = 1.3f;
left->tracking_origin->offset.position.z = -0.5f;
}
if (right != NULL &&
right->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
right->tracking_origin->offset.position.x = 0.2f;
right->tracking_origin->offset.position.y = 1.3f;
right->tracking_origin->offset.position.z = -0.5f;
}
//! @todo handle other subaction paths?
sys->inst = inst;
@ -189,6 +159,8 @@ oxr_system_fill_in(struct oxr_logger *log,
sys->views[1].maxSwapchainSampleCount = info->views[1].max.sample_count;
// clang-format on
struct xrt_device *head = GET_XDEV_BY_ROLE(sys, head);
uint32_t i = 0;
if (head->hmd->blend_mode & XRT_BLEND_MODE_OPAQUE) {
sys->blend_modes[i++] = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;