The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

t/common: Refactor RGB builder [NFC]

+28 -14
+28 -14
src/xrt/targets/common/target_builder_rgb_tracking.c
··· 290 290 assert(out_xsysd != NULL); 291 291 assert(*out_xsysd == NULL); 292 292 293 - struct u_system_devices *usysd = u_system_devices_allocate(); 293 + struct xrt_tracking_origin *origin = NULL; 294 + struct xrt_system_devices *xsysd = NULL; 295 + struct xrt_frame_context *xfctx = NULL; 296 + 297 + { 298 + struct u_system_devices *usysd = u_system_devices_allocate(); 299 + xsysd = &usysd->base; 300 + xfctx = &usysd->xfctx; 301 + origin = &usysd->origin; 302 + } 294 303 295 304 296 305 /* ··· 300 309 struct build_state build = {0}; 301 310 if (get_settings(config, &build.settings)) { 302 311 #ifdef XRT_HAVE_OPENCV 303 - build.xfctx = &usysd->xfctx; 304 - build.origin = &usysd->origin; 312 + build.xfctx = xfctx; 313 + build.origin = origin; 305 314 build.origin->type = XRT_TRACKING_TYPE_RGB; 306 315 build.origin->offset.orientation.y = 1.0f; 307 316 build.origin->offset.position.z = -2.0f; ··· 323 332 // Lock the device list 324 333 xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count); 325 334 if (xret != XRT_SUCCESS) { 326 - u_system_devices_destroy(&usysd); 335 + xrt_system_devices_destroy(&xsysd); 327 336 return xret; 328 337 } 329 338 ··· 383 392 // Unlock the device list 384 393 xret = xrt_prober_unlock_list(xp, &xpdevs); 385 394 if (xret != XRT_SUCCESS) { 386 - u_system_devices_destroy(&usysd); 395 + xrt_system_devices_destroy(&xsysd); 387 396 return xret; 388 397 } 389 398 390 - 391 - usysd->base.xdevs[usysd->base.xdev_count++] = head; 392 - usysd->base.roles.head = head; 399 + // Add to devices. 400 + xsysd->xdevs[xsysd->xdev_count++] = head; 393 401 402 + struct xrt_device *left = NULL, *right = NULL; 394 403 if (psmv_red != NULL) { 395 - usysd->base.xdevs[usysd->base.xdev_count++] = psmv_red; 396 - usysd->base.roles.right = psmv_red; 404 + xsysd->xdevs[xsysd->xdev_count++] = psmv_red; 405 + right = psmv_red; // Notice right. 397 406 } 398 407 399 408 if (psmv_purple != NULL) { 400 - usysd->base.xdevs[usysd->base.xdev_count++] = psmv_purple; 401 - usysd->base.roles.left = psmv_purple; 409 + xsysd->xdevs[xsysd->xdev_count++] = psmv_purple; 410 + left = psmv_purple; // Notice left. 402 411 } 403 412 413 + // Assign to role(s). 414 + xsysd->roles.head = head; 415 + xsysd->roles.left = left; 416 + xsysd->roles.right = right; 417 + 404 418 405 419 /* 406 420 * Done. 407 421 */ 408 422 409 - *out_xsysd = &usysd->base; 410 - u_builder_create_space_overseer(&usysd->base, out_xso); 423 + *out_xsysd = xsysd; 424 + u_builder_create_space_overseer(xsysd, out_xso); 411 425 412 426 return XRT_SUCCESS; 413 427 }