[Bf-blender-cvs] [4f9451c0442] master: Camera: change how the minimum near clip depth is set
Campbell Barton
noreply at git.blender.org
Fri Mar 22 15:20:15 CET 2019
Commit: 4f9451c044218b9b8a09b7355cea883b7320f9f0
Author: Campbell Barton
Date: Sat Mar 23 01:13:04 2019 +1100
Branches: master
https://developer.blender.org/rB4f9451c044218b9b8a09b7355cea883b7320f9f0
Camera: change how the minimum near clip depth is set
do_clip wasn't working for its intended purpose,
replace with a simpler method.
===================================================================
M source/blender/blenkernel/intern/camera.c
M source/blender/draw/modes/object_mode.c
===================================================================
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index a1d43d24716..79d28cb08a7 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -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])
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 82a660dfd5f..1af6a5fff5d 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -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]);
More information about the Bf-blender-cvs
mailing list