From eee17ee2fffe1b2d0d0cc80c6ee8e9d9c9c6c2b6 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 17 Oct 2023 01:50:29 +0100 Subject: [PATCH] u/builders: Refactor space overseer creation helper --- src/xrt/auxiliary/util/u_builders.c | 15 ++++++++++----- src/xrt/auxiliary/util/u_builders.h | 13 ++++++++++--- src/xrt/targets/common/target_builder_legacy.c | 8 +++++++- .../targets/common/target_builder_lighthouse.c | 8 +++++++- .../targets/common/target_builder_north_star.c | 8 +++++++- src/xrt/targets/common/target_builder_nreal_air.c | 8 +++++++- src/xrt/targets/common/target_builder_qwerty.c | 8 +++++++- src/xrt/targets/common/target_builder_remote.c | 8 +++++++- .../targets/common/target_builder_rgb_tracking.c | 9 ++++++++- src/xrt/targets/common/target_builder_rift_s.c | 8 +++++++- src/xrt/targets/common/target_builder_simulated.c | 8 +++++++- src/xrt/targets/common/target_builder_simulavr.c | 8 +++++++- src/xrt/targets/common/target_builder_wmr.c | 9 ++++++++- src/xrt/targets/sdl_test/sdl_instance.c | 8 +++++++- 14 files changed, 106 insertions(+), 20 deletions(-) diff --git a/src/xrt/auxiliary/util/u_builders.c b/src/xrt/auxiliary/util/u_builders.c index 48a6da764..bafdbc16f 100644 --- a/src/xrt/auxiliary/util/u_builders.c +++ b/src/xrt/auxiliary/util/u_builders.c @@ -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; } diff --git a/src/xrt/auxiliary/util/u_builders.h b/src/xrt/auxiliary/util/u_builders.h index 3ca7d94df..ac62d14ed 100644 --- a/src/xrt/auxiliary/util/u_builders.h +++ b/src/xrt/auxiliary/util/u_builders.h @@ -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 diff --git a/src/xrt/targets/common/target_builder_legacy.c b/src/xrt/targets/common/target_builder_legacy.c index 0a3a0e8f9..6747e0dd2 100644 --- a/src/xrt/targets/common/target_builder_legacy.c +++ b/src/xrt/targets/common/target_builder_legacy.c @@ -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; } diff --git a/src/xrt/targets/common/target_builder_lighthouse.c b/src/xrt/targets/common/target_builder_lighthouse.c index 2f07a1991..e94e162d4 100644 --- a/src/xrt/targets/common/target_builder_lighthouse.c +++ b/src/xrt/targets/common/target_builder_lighthouse.c @@ -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; diff --git a/src/xrt/targets/common/target_builder_north_star.c b/src/xrt/targets/common/target_builder_north_star.c index b699f27e2..041805c64 100644 --- a/src/xrt/targets/common/target_builder_north_star.c +++ b/src/xrt/targets/common/target_builder_north_star.c @@ -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); } diff --git a/src/xrt/targets/common/target_builder_nreal_air.c b/src/xrt/targets/common/target_builder_nreal_air.c index aedd73492..645265a9e 100644 --- a/src/xrt/targets/common/target_builder_nreal_air.c +++ b/src/xrt/targets/common/target_builder_nreal_air.c @@ -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; diff --git a/src/xrt/targets/common/target_builder_qwerty.c b/src/xrt/targets/common/target_builder_qwerty.c index c02704d28..7707219a5 100644 --- a/src/xrt/targets/common/target_builder_qwerty.c +++ b/src/xrt/targets/common/target_builder_qwerty.c @@ -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; } diff --git a/src/xrt/targets/common/target_builder_remote.c b/src/xrt/targets/common/target_builder_remote.c index 4243f5f59..0caf5494a 100644 --- a/src/xrt/targets/common/target_builder_remote.c +++ b/src/xrt/targets/common/target_builder_remote.c @@ -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; } diff --git a/src/xrt/targets/common/target_builder_rgb_tracking.c b/src/xrt/targets/common/target_builder_rgb_tracking.c index d9343b62a..10ef4482d 100644 --- a/src/xrt/targets/common/target_builder_rgb_tracking.c +++ b/src/xrt/targets/common/target_builder_rgb_tracking.c @@ -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; } diff --git a/src/xrt/targets/common/target_builder_rift_s.c b/src/xrt/targets/common/target_builder_rift_s.c index 14f5efee0..fa25ad31c 100644 --- a/src/xrt/targets/common/target_builder_rift_s.c +++ b/src/xrt/targets/common/target_builder_rift_s.c @@ -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: diff --git a/src/xrt/targets/common/target_builder_simulated.c b/src/xrt/targets/common/target_builder_simulated.c index 635c7f13d..16eb94cf3 100644 --- a/src/xrt/targets/common/target_builder_simulated.c +++ b/src/xrt/targets/common/target_builder_simulated.c @@ -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; } diff --git a/src/xrt/targets/common/target_builder_simulavr.c b/src/xrt/targets/common/target_builder_simulavr.c index 7f16fcd70..c53350ccf 100644 --- a/src/xrt/targets/common/target_builder_simulavr.c +++ b/src/xrt/targets/common/target_builder_simulavr.c @@ -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); } diff --git a/src/xrt/targets/common/target_builder_wmr.c b/src/xrt/targets/common/target_builder_wmr.c index bf4e061fd..bd16edf33 100644 --- a/src/xrt/targets/common/target_builder_wmr.c +++ b/src/xrt/targets/common/target_builder_wmr.c @@ -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); diff --git a/src/xrt/targets/sdl_test/sdl_instance.c b/src/xrt/targets/sdl_test/sdl_instance.c index 5d8fc168b..d2ee08e7a 100644 --- a/src/xrt/targets/sdl_test/sdl_instance.c +++ b/src/xrt/targets/sdl_test/sdl_instance.c @@ -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