u/builders: Refactor space overseer creation helper

This commit is contained in:
Jakob Bornecrantz 2023-10-17 01:50:29 +01:00
parent e805209fcd
commit eee17ee2ff
14 changed files with 106 additions and 20 deletions

View file

@ -143,7 +143,12 @@ u_builder_setup_tracking_origins(struct xrt_device *head,
}
void
u_builder_create_space_overseer(struct xrt_system_devices *xsysd, struct xrt_space_overseer **out_xso)
u_builder_create_space_overseer_legacy(struct xrt_device *head,
struct xrt_device *left,
struct xrt_device *right,
struct xrt_device **xdevs,
uint32_t xdev_count,
struct xrt_space_overseer **out_xso)
{
/*
* Tracking origins.
@ -156,9 +161,9 @@ u_builder_create_space_overseer(struct xrt_system_devices *xsysd, struct xrt_spa
};
u_builder_setup_tracking_origins( //
xsysd->roles.head, //
xsysd->roles.left, //
xsysd->roles.right, //
head, //
left, //
right, //
&global_tracking_origin_offset); //
@ -171,7 +176,7 @@ u_builder_create_space_overseer(struct xrt_system_devices *xsysd, struct xrt_spa
struct xrt_pose T_stage_local = XRT_POSE_IDENTITY;
T_stage_local.position.y = 1.6;
u_space_overseer_legacy_setup(uso, xsysd->xdevs, xsysd->xdev_count, xsysd->roles.head, &T_stage_local);
u_space_overseer_legacy_setup(uso, xdevs, xdev_count, head, &T_stage_local);
*out_xso = (struct xrt_space_overseer *)uso;
}

View file

@ -90,13 +90,20 @@ u_builder_setup_tracking_origins(struct xrt_device *head,
struct xrt_vec3 *global_tracking_origin_offset);
/*!
* Create a legacy space overseer, most builders probably want to have more
* smart then this especially stand alone ones.
* Create a legacy space overseer, most builders probably want to have a more
* advanced setup then this, especially stand alone ones. Uses
* @ref u_builder_setup_tracking_origins internally and
* @ref u_space_overseer_legacy_setup.
*
* @ingroup aux_util
*/
void
u_builder_create_space_overseer(struct xrt_system_devices *xsysd, struct xrt_space_overseer **out_xso);
u_builder_create_space_overseer_legacy(struct xrt_device *head,
struct xrt_device *left,
struct xrt_device *right,
struct xrt_device **xdevs,
uint32_t xdev_count,
struct xrt_space_overseer **out_xso);
#ifdef __cplusplus

View file

@ -190,7 +190,13 @@ legacy_open_system(struct xrt_builder *xb,
*/
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return XRT_SUCCESS;
}

View file

@ -806,7 +806,13 @@ end_valve_index:
xsysd->roles.hand_tracking.right = right_ht;
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return XRT_SUCCESS;

View file

@ -588,7 +588,13 @@ ns_open_system(struct xrt_builder *xb,
end:
if (result == XRT_SUCCESS) {
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head_wrap, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
} else {
xrt_system_devices_destroy(&xsysd);
}

View file

@ -149,7 +149,13 @@ nreal_air_open_system(struct xrt_builder *xb,
*/
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
na_device, // head
NULL, // left
NULL, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return XRT_SUCCESS;

View file

@ -113,7 +113,13 @@ qwerty_open_system(struct xrt_builder *xb,
*/
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return XRT_SUCCESS;
}

View file

@ -94,7 +94,13 @@ remote_open_system(struct xrt_builder *xb,
}
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
xsysd->roles.head, // head
xsysd->roles.left, // left
xsysd->roles.right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return xret;
}

View file

@ -421,7 +421,14 @@ rgb_open_system(struct xrt_builder *xb,
*/
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return XRT_SUCCESS;
}

View file

@ -203,7 +203,13 @@ rift_s_open_system(struct xrt_builder *xb,
*/
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
hmd_xdev, // head
left_xdev, // left
right_xdev, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
unlock_and_fail:

View file

@ -145,7 +145,13 @@ simulated_open_system(struct xrt_builder *xb,
*/
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
return XRT_SUCCESS;
}

View file

@ -226,7 +226,13 @@ svr_open_system(struct xrt_builder *xb,
end:
if (result == XRT_SUCCESS) {
*out_xsysd = xsysd;
u_builder_create_space_overseer(xsysd, out_xso);
u_builder_create_space_overseer_legacy( //
head_device, // head
NULL, // left
NULL, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
out_xso); // out_xso
} else {
xrt_system_devices_destroy(&xsysd);
}

View file

@ -307,9 +307,16 @@ wmr_open_system(struct xrt_builder *xb,
xsysd->roles.hand_tracking.left = ht_left;
xsysd->roles.hand_tracking.right = ht_right;
// Create space overseer last once all devices set.
struct xrt_space_overseer *xso = NULL;
u_builder_create_space_overseer(xsysd, &xso);
u_builder_create_space_overseer_legacy( //
head, // head
left, // left
right, // right
xsysd->xdevs, // xdevs
xsysd->xdev_count, // xdev_count
&xso); // out_xso
assert(xso != NULL);

View file

@ -113,7 +113,13 @@ sdl_system_devices_init(struct sdl_program *sp)
sp->xsysd_base.xdev_count = 1;
sp->xsysd_base.roles.head = head;
u_builder_create_space_overseer(&sp->xsysd_base, &sp->xso);
u_builder_create_space_overseer_legacy( //
head, // head
NULL, // left
NULL, // right
sp->xsysd_base.xdevs, // xdevs
sp->xsysd_base.xdev_count, // xdev_count
&sp->xso); // out_xso
}
void