From 38f1b35ac0e72c6040457445c9740233fabf6065 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Fri, 20 Oct 2023 14:10:04 -0400 Subject: [PATCH] c/util: Compute eye and world inverse view matrix Co-authored-by: Charlton Rodda Co-authored-by: Jakob Bornecrantz --- src/xrt/compositor/util/comp_render_gfx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/xrt/compositor/util/comp_render_gfx.c b/src/xrt/compositor/util/comp_render_gfx.c index 39d13cb4f..38ceb451b 100644 --- a/src/xrt/compositor/util/comp_render_gfx.c +++ b/src/xrt/compositor/util/comp_render_gfx.c @@ -49,6 +49,12 @@ struct gfx_view_state struct xrt_matrix_4x4 world_vp_full; // Full rotation and translation VP matrix, in view space. struct xrt_matrix_4x4 eye_vp_full; + + // Full rotation and translation inverse V matrix, in world space. + struct xrt_matrix_4x4 world_v_inv_full; + // Full rotation and translation inverse V matrix, in view space. + struct xrt_matrix_4x4 eye_v_inv_full; + // Only rotation and translation VP matrix, in world space. struct xrt_matrix_4x4 world_vp_rot_only; // Only rotation and translation VP matrix, in view space. @@ -275,6 +281,7 @@ do_layers(struct render_gfx *rr, // World math_matrix_4x4_view_from_pose(&world_poses[view], &v); math_matrix_4x4_multiply(&p, &v, &views[view].world_vp_full); + math_matrix_4x4_inverse(&v, &views[view].world_v_inv_full); struct xrt_pose world_rot_only = {world_poses[view].orientation, XRT_VEC3_ZERO}; math_matrix_4x4_view_from_pose(&world_rot_only, &v); @@ -283,6 +290,7 @@ do_layers(struct render_gfx *rr, // Eye math_matrix_4x4_view_from_pose(&eye_poses[view], &v); math_matrix_4x4_multiply(&p, &v, &views[view].eye_vp_full); + math_matrix_4x4_inverse(&v, &views[view].eye_v_inv_full); struct xrt_pose eye_rot_only = {eye_poses[view].orientation, XRT_VEC3_ZERO}; math_matrix_4x4_view_from_pose(&eye_rot_only, &v);