The open source OpenXR runtime

st/oxr: Add view rotation difference to fov angles with parallel views

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2312>

authored by

Christoph Haag and committed by
Marge Bot
d1f4099a 71b5d37e

+28 -1
+28 -1
src/xrt/state_trackers/oxr/oxr_session.c
··· 513 513 return res; 514 514 } 515 515 516 + static void 517 + adjust_fov(const struct xrt_fov *original_fov, const struct xrt_quat *original_rotation, struct xrt_fov *adjusted_fov) 518 + { 519 + struct xrt_quat identity = XRT_QUAT_IDENTITY; 520 + 521 + struct xrt_quat original_rotation_inv; 522 + math_quat_invert(original_rotation, &original_rotation_inv); 523 + 524 + struct xrt_quat rotation_diff; 525 + math_quat_rotate(&original_rotation_inv, &identity, &rotation_diff); 526 + 527 + struct xrt_vec3 euler_angles; 528 + math_quat_to_euler_angles(&rotation_diff, &euler_angles); 529 + 530 + *adjusted_fov = (struct xrt_fov){ 531 + .angle_left = original_fov->angle_left + euler_angles.y, 532 + .angle_right = original_fov->angle_right + euler_angles.y, 533 + .angle_up = original_fov->angle_up + euler_angles.x, 534 + .angle_down = original_fov->angle_down + euler_angles.x, 535 + }; 536 + } 537 + 516 538 XrResult 517 539 oxr_session_locate_views(struct oxr_logger *log, 518 540 struct oxr_session *sess, ··· 633 655 * Fov 634 656 */ 635 657 636 - const struct xrt_fov fov = fovs[i]; 658 + struct xrt_fov fov = fovs[i]; 659 + 660 + if (sess->sys->inst->quirks.parallel_views) { 661 + adjust_fov(&fovs[i], &poses[i].orientation, &fov); 662 + } 663 + 637 664 OXR_XRT_FOV_TO_XRFOVF(fov, views[i].fov); 638 665 639 666