[Bf-blender-cvs] [4ae1815] master: Fix viewport camera dof object distance

Campbell Barton noreply at git.blender.org
Sun Sep 6 18:40:15 CEST 2015


Commit: 4ae181543fb87f2b58033cf05c849a2069fe1751
Author: Campbell Barton
Date:   Mon Sep 7 02:32:34 2015 +1000
Branches: master
https://developer.blender.org/rB4ae181543fb87f2b58033cf05c849a2069fe1751

Fix viewport camera dof object distance

Also use simpler method to calculate the depth.

===================================================================

M	source/blender/blenkernel/intern/camera.c

===================================================================

diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index b67f553..7e043df 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -169,15 +169,15 @@ float BKE_camera_object_dof_distance(Object *ob)
 	if (ob->type != OB_CAMERA)
 		return 0.0f;
 	if (cam->dof_ob) {
-		/* too simple, better to return the distance on the view axis only
-		 * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */
-		float mat[4][4], imat[4][4], obmat[4][4];
-		
-		copy_m4_m4(obmat, ob->obmat);
-		normalize_m4(obmat);
-		invert_m4_m4(imat, obmat);
-		mul_m4_m4m4(mat, imat, cam->dof_ob->obmat);
-		return fabsf(mat[3][2]);
+#if 0
+		/* too simple, better to return the distance on the view axis only */
+		return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]);
+#else
+		float view_dir[3], dof_dir[3];
+		normalize_v3_v3(view_dir, ob->obmat[2]);
+		sub_v3_v3v3(dof_dir, ob->obmat[3], cam->dof_ob->obmat[3]);
+		return fabsf(dot_v3v3(view_dir, dof_dir));
+#endif
 	}
 	return cam->YF_dofdist;
 }
@@ -958,11 +958,6 @@ void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_set
 		r_fx_settings->dof = &cam->gpu_dof;
 		r_fx_settings->dof->focal_length = cam->lens;
 		r_fx_settings->dof->sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
-		if (cam->dof_ob) {
-			r_fx_settings->dof->focus_distance = len_v3v3(cam->dof_ob->obmat[3], camera->obmat[3]);
-		}
-		else {
-			r_fx_settings->dof->focus_distance = cam->YF_dofdist;
-		}
+		r_fx_settings->dof->focus_distance = BKE_camera_object_dof_distance(camera);
 	}
 }




More information about the Bf-blender-cvs mailing list