Fix T98799: camera unselectable in camera view below a certain scale

The camera frame (used for selection) was drawn outside the near
clipping plane in those cases.

This has been an issue before as seen in the following commits:
- rB6e7e6832e87
- rB33d322873e6
- rB4f9451c0442

Remaining issue was that the code which ensure the frame isn't behind
the near clipping plane was not taking into account the camera could be
scaled (in Z).
A caller of `BKE_camera_view_frame_ex` (namely
`OVERLAY_camera_cache_populate`) applies scale (also on the depth) which
does not play well with the way `BKE_camera_view_frame_ex` did it.

Now take Z scale into account.

Ref D15178
This commit is contained in:
Philipp Oeser 2022-06-28 15:51:19 +10:00 committed by Campbell Barton
parent e6d50cdd43
commit 33fc230ba2
Notes: blender-bot 2023-02-14 03:13:26 +01:00
Referenced by issue #98799, Cannot select camera by clicking on the border edge, if the scale is below 0.51
1 changed files with 1 additions and 1 deletions

View File

@ -528,7 +528,7 @@ void BKE_camera_view_frame_ex(const Scene *scene,
if (do_clip) {
/* Ensure the frame isn't behind the near clipping plane, T62814. */
float fac = (camera->clip_start + 0.1f) / -r_vec[0][2];
float fac = ((camera->clip_start + 0.1f) / -r_vec[0][2]) * scale[2];
for (uint i = 0; i < 4; i++) {
if (camera->type == CAM_ORTHO) {
r_vec[i][2] *= fac;