The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Use xrt_device_get_view_poses

Co-authored-by: Christoph Haag <christoph.haag@collabora.com>

+56 -11
+56 -11
src/xrt/state_trackers/oxr/oxr_session.c
··· 365 365 U_LOG_D("viewLocateInfo->displayTime %" PRIu64, viewLocateInfo->displayTime); 366 366 } 367 367 368 + /* 369 + * Get head relation, fovs and view poses. 370 + */ 371 + 372 + // To be passed down to the devices, some can override this. 373 + const struct xrt_vec3 default_eye_relation = { 374 + sess->ipd_meters, 375 + 0.0f, 376 + 0.0f, 377 + }; 378 + 379 + const uint64_t xdisplay_time = 380 + time_state_ts_to_monotonic_ns(sess->sys->inst->timekeeping, viewLocateInfo->displayTime); 381 + //! @todo Head relation currently not used. 382 + struct xrt_space_relation head_relation = XRT_SPACE_RELATION_ZERO; 383 + struct xrt_fov fovs[2] = {0}; 384 + struct xrt_pose poses[2] = {0}; 385 + 386 + xrt_device_get_view_poses( // 387 + xdev, // 388 + &default_eye_relation, // 389 + xdisplay_time, // 390 + 2, // 391 + &head_relation, // 392 + fovs, // 393 + poses); 394 + 395 + 396 + /* 397 + * Get the pure_relation if needed. 398 + */ 399 + 368 400 // Get the viewLocateInfo->space to view space relation. 369 401 struct xrt_space_relation pure_relation; 402 + 403 + /*! 404 + * @todo Introduce oxr_space_ref_relation_with_relation that takes 405 + * relation and transforms it into the correct relationship. 406 + */ 407 + // If we are going from stage space use the head pose. 370 408 oxr_space_ref_relation( // 371 409 log, // 372 410 sess, // ··· 381 419 382 420 viewState->viewStateFlags = 0; 383 421 384 - //! @todo Do not hardcode IPD. 385 - const struct xrt_vec3 eye_relation = { 386 - sess->ipd_meters, 387 - 0.0f, 388 - 0.0f, 389 - }; 422 + 390 423 391 424 for (uint32_t i = 0; i < view_count; i++) { 392 - struct xrt_pose view_pose = XRT_POSE_IDENTITY; 425 + /* 426 + * Pose 427 + */ 393 428 394 - // Get the per view pose from the device. 395 - xrt_device_get_view_pose(xdev, &eye_relation, i, &view_pose); 429 + const struct xrt_pose view_pose = poses[i]; 396 430 397 431 // Do the magical space relation dance here. 398 432 struct xrt_space_relation result = {0}; ··· 408 442 safe_copy_pose.xrt = result.pose; 409 443 views[i].pose = safe_copy_pose.oxr; 410 444 411 - // Copy the fov information directly from the device. 445 + 446 + /* 447 + * Fov 448 + */ 449 + 450 + const struct xrt_fov fov = fovs[i]; 451 + 412 452 union { 413 453 struct xrt_fov xrt; 414 454 XrFovf oxr; 415 455 } safe_copy_fov = {0}; 416 - safe_copy_fov.xrt = xdev->hmd->views[i].fov; 456 + safe_copy_fov.xrt = fov; 417 457 views[i].fov = safe_copy_fov.oxr; 458 + 459 + 460 + /* 461 + * Checking, debug and flag handling. 462 + */ 418 463 419 464 struct xrt_pose *pose = (struct xrt_pose *)&views[i].pose; 420 465 if ((result.relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0 &&