Camera: change how the minimum near clip depth is set
do_clip wasn't working for its intended purpose, replace with a simpler method.
This commit is contained in:
parent
33d322873e
commit
4f9451c044
Notes:
blender-bot
2023-02-14 05:25:44 +01:00
Referenced by commit 33fc230ba2
, Fix T98799: camera unselectable in camera view below a certain scale
|
@ -366,7 +366,7 @@ void BKE_camera_view_frame_ex(
|
|||
facy = 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
|
||||
r_shift[0] = camera->shiftx * camera->ortho_scale * scale[0];
|
||||
r_shift[1] = camera->shifty * camera->ortho_scale * scale[1];
|
||||
depth = do_clip ? -((camera->clip_start * scale[2]) + 0.1f) : -drawsize * scale[2];
|
||||
depth = -drawsize * scale[2];
|
||||
|
||||
*r_drawsize = 0.5f * camera->ortho_scale;
|
||||
}
|
||||
|
@ -376,24 +376,12 @@ void BKE_camera_view_frame_ex(
|
|||
float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ?
|
||||
(camera->sensor_y) : (camera->sensor_x));
|
||||
|
||||
|
||||
if (do_clip) {
|
||||
/* fixed depth, variable size (avoids exceeding clipping range) */
|
||||
/* r_drawsize shouldn't be used in this case, set to dummy value */
|
||||
*r_drawsize = 1.0f;
|
||||
depth = -(camera->clip_start + 0.1f) * scale[2];
|
||||
fac = depth / (camera->lens / (-half_sensor));
|
||||
scale_x = scale[0] / scale[2];
|
||||
scale_y = scale[1] / scale[2];
|
||||
}
|
||||
else {
|
||||
/* fixed size, variable depth (stays a reasonable size in the 3D view) */
|
||||
*r_drawsize = (drawsize / 2.0f) / ((scale[0] + scale[1] + scale[2]) / 3.0f);
|
||||
depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
|
||||
fac = *r_drawsize;
|
||||
scale_x = scale[0];
|
||||
scale_y = scale[1];
|
||||
}
|
||||
/* fixed size, variable depth (stays a reasonable size in the 3D view) */
|
||||
*r_drawsize = (drawsize / 2.0f) / ((scale[0] + scale[1] + scale[2]) / 3.0f);
|
||||
depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
|
||||
fac = *r_drawsize;
|
||||
scale_x = scale[0];
|
||||
scale_y = scale[1];
|
||||
|
||||
facx = fac * r_asp[0] * scale_x;
|
||||
facy = fac * r_asp[1] * scale_y;
|
||||
|
@ -405,6 +393,19 @@ void BKE_camera_view_frame_ex(
|
|||
r_vec[1][0] = r_shift[0] + facx; r_vec[1][1] = r_shift[1] - facy; r_vec[1][2] = depth;
|
||||
r_vec[2][0] = r_shift[0] - facx; r_vec[2][1] = r_shift[1] - facy; r_vec[2][2] = depth;
|
||||
r_vec[3][0] = r_shift[0] - facx; r_vec[3][1] = r_shift[1] + facy; r_vec[3][2] = depth;
|
||||
|
||||
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];
|
||||
for (uint i = 0; i < 4; i++) {
|
||||
if (camera->type == CAM_ORTHO) {
|
||||
r_vec[i][2] *= fac;
|
||||
}
|
||||
else {
|
||||
mul_v3_fl(r_vec[i], fac);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_camera_view_frame(const Scene *scene, const Camera *camera, float r_vec[4][3])
|
||||
|
|
|
@ -1850,24 +1850,9 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
|
|||
scale[2] = 1.0f / len_v3(ob->obmat[2]);
|
||||
}
|
||||
|
||||
BKE_camera_view_frame_ex(scene, cam, cam->drawsize, false, scale,
|
||||
BKE_camera_view_frame_ex(scene, cam, cam->drawsize, look_through, scale,
|
||||
asp, shift, &drawsize, vec);
|
||||
|
||||
if (look_through) {
|
||||
/* Ensure the frame isn't behind the near clipping plane, T62814. */
|
||||
float fac = (cam->clip_start + 0.1f) / -vec[0][2];
|
||||
if (fac > 1.0f) {
|
||||
for (uint i = 0; i < 4; i++) {
|
||||
if (rv3d->is_persp) {
|
||||
mul_v3_fl(vec[i], fac);
|
||||
}
|
||||
else {
|
||||
vec[i][2] *= fac;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Frame coords */
|
||||
copy_v2_v2(cam->runtime.drw_corners[0][0], vec[0]);
|
||||
copy_v2_v2(cam->runtime.drw_corners[0][1], vec[1]);
|
||||
|
|
Loading…
Reference in New Issue