diff options
author | Peter Kim <pk15950@gmail.com> | 2021-10-26 07:33:21 +0300 |
---|---|---|
committer | Peter Kim <pk15950@gmail.com> | 2021-10-26 07:35:12 +0300 |
commit | 7ae2810848338033d9e71834a2cea294025cb214 (patch) | |
tree | 5c8776296e11952274d70e9392a40b53f36906ad /source/blender/draw/intern | |
parent | 3434a991ec5befef19c5484bfc70a3a333e42c34 (diff) |
XR: View adjustments for variable viewer scale
This adjusts some calculations and visibility flags for XR viewports in
order to account for a possible scale factor in the XR view matrix.
This scale factor can be introduced via the XR session settings base
scale, which allows a viewer to begin their session at a specific
reference scale, or the XR session state navigation scale, which allows
a viewer to adjust their scale relative to the reference scale during
the session.
Reviewed by Severin as part of D11501, but requested to be committed
separately.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index f96bd474aec..5d3e3db866f 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -1684,10 +1684,12 @@ static void draw_frustum_bound_sphere_calc(const BoundBox *bbox, bsphere->center[0] = farcenter[0] * z / e; bsphere->center[1] = farcenter[1] * z / e; bsphere->center[2] = z; - bsphere->radius = len_v3v3(bsphere->center, farpoint); - /* Transform to world space. */ - mul_m4_v3(viewinv, bsphere->center); + /* For XR, the view matrix may contain a scale factor. Then, transforming only the center + * into world space after calculating the radius will result in incorrect behavior. */ + mul_m4_v3(viewinv, bsphere->center); /* Transform to world space. */ + mul_m4_v3(viewinv, farpoint); + bsphere->radius = len_v3v3(bsphere->center, farpoint); } } |