[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12125] trunk/blender/source/blender: Dof Object - set the depth of field to an object - set in the camera edit panel but the distance is calculated on the camera object only so linked cameras work .

Campbell Barton cbarton at metavr.com
Sun Sep 23 20:27:01 CEST 2007


Revision: 12125
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12125
Author:   campbellbarton
Date:     2007-09-23 20:27:01 +0200 (Sun, 23 Sep 2007)

Log Message:
-----------
Dof Object - set the depth of field to an object - set in the camera edit panel but the distance is calculated on the camera object only so linked cameras work.
Alt+Period - sets active pivot

some tooltips didnt make much sense, edited a few.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_object.h
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_camera_types.h
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
    trunk/blender/source/blender/nodes/intern/CMP_util.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/drawobject.c
    trunk/blender/source/blender/src/header_view3d.c
    trunk/blender/source/blender/src/space.c

Modified: trunk/blender/source/blender/blenkernel/BKE_object.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_object.h	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/blenkernel/BKE_object.h	2007-09-23 18:27:01 UTC (rev 12125)
@@ -63,6 +63,7 @@
 void *add_camera(char *name);
 struct Camera *copy_camera(struct Camera *cam);
 void make_local_camera(struct Camera *cam);
+float dof_camera(struct Object *ob);
 void *add_lamp(char *name);
 struct Lamp *copy_lamp(struct Lamp *la);
 void make_local_lamp(struct Lamp *la);

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2007-09-23 18:27:01 UTC (rev 12125)
@@ -44,6 +44,7 @@
 #include "DNA_action_types.h"
 #include "DNA_armature_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_camera_types.h"
 #include "DNA_ID.h"
 #include "DNA_effect_types.h"
 #include "DNA_group_types.h"
@@ -479,7 +480,13 @@
 		dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB);
 		/* inverted relation, so addtoroot shouldn't be set to zero */
 	}
-	
+	if (ob->type==OB_CAMERA) {
+		Camera *cam = (Camera *)ob->data;
+		if (cam->dof_ob) {
+			node2 = dag_get_node(dag, cam->dof_ob);
+			dag_add_relation(dag,node2,node,DAG_RL_OB_OB);
+		}
+	}
 	if (ob->transflag & OB_DUPLI) {
 		if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
 			GroupObject *go;

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2007-09-23 18:27:01 UTC (rev 12125)
@@ -260,6 +260,7 @@
 	Tex *tex;
 	Ipo *ipo;
 	Group *group;
+	Camera *camera;
 	bConstraint *con;
 	bActionStrip *strip;
 	int a;
@@ -473,6 +474,15 @@
 		rem_from_group(group, ob);
 		group= group->id.next;
 	}
+	
+	/* cameras */
+	camera= G.main->camera.first;
+	while(camera) {
+		if (camera->dof_ob==ob) {
+			camera->dof_ob = NULL;
+		}
+		camera= camera->id.next;
+	}
 }
 
 int exist_object(Object *obtest)
@@ -573,8 +583,24 @@
 	}
 }
 
+/* get the camera's dof value, takes the dof object into account */
+float dof_camera(Object *ob)
+{
+	Camera *cam = (Camera *)ob->data; 
+	if (ob->type != OB_CAMERA)
+		return 0.0;
+	if (cam->dof_ob) {	
+		/* too simple, better to return the distance on the view axis only
+		 * return VecLenf(ob->obmat[3], cam->dof_ob->obmat[3]); */
+		
+		float mat[4][4];
+		Mat4Invert(ob->imat, ob->obmat);
+		Mat4MulMat4(mat, cam->dof_ob->obmat, ob->imat);
+		return fabs(mat[3][2]);
+	}
+	return cam->YF_dofdist;
+}
 
-
 void *add_lamp(char *name)
 {
 	Lamp *la;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2007-09-23 18:27:01 UTC (rev 12125)
@@ -1864,7 +1864,9 @@
 		if(ca->id.flag & LIB_NEEDLINK) {
 
 			ca->ipo= newlibadr_us(fd, ca->id.lib, ca->ipo);
-
+			
+			ca->dof_ob= newlibadr_us(fd, ca->id.lib, ca->dof_ob);
+			
 			lib_link_scriptlink(fd, &ca->id, &ca->scriptlink);
 
 			ca->id.flag -= LIB_NEEDLINK;
@@ -6067,8 +6069,6 @@
 			if(arm->layer==0) arm->layer= 1;
 		}
 		for(sce= main->scene.first; sce; sce= sce->id.next) {
-			bScreen *sc;
-			
 			if(sce->jumpframe==0) sce->jumpframe= 10;
 			if(sce->audio.mixrate==0) sce->audio.mixrate= 44100;
 

Modified: trunk/blender/source/blender/makesdna/DNA_camera_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_camera_types.h	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/makesdna/DNA_camera_types.h	2007-09-23 18:27:01 UTC (rev 12125)
@@ -42,6 +42,7 @@
 #endif
 
 struct Ipo;
+struct Object;
 
 typedef struct Camera {
 	ID id;
@@ -62,6 +63,7 @@
 	struct Ipo *ipo;
 	
 	ScriptLink scriptlink;
+	struct Object *dof_ob;
 } Camera;
 
 /* **************** CAMERA ********************* */

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c	2007-09-23 18:27:01 UTC (rev 12125)
@@ -257,7 +257,8 @@
 	if (camob && camob->type==OB_CAMERA) {
 		Camera* cam = (Camera*)camob->data;
 		cam_lens = cam->lens;
-		cam_fdist = (cam->YF_dofdist==0.f) ? 1e10f : cam->YF_dofdist;
+		cam_fdist = dof_camera(camob);
+		if (cam_fdist==0.0) cam_fdist = 1e10f; /* if the dof is 0.0 then set it be be far away */ 
 		cam_invfdist = 1.f/cam_fdist;
 	}
 

Modified: trunk/blender/source/blender/nodes/intern/CMP_util.h
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_util.h	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/nodes/intern/CMP_util.h	2007-09-23 18:27:01 UTC (rev 12125)
@@ -60,6 +60,7 @@
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 #include "BKE_library.h"
+#include "BKE_object.h"
 
 #include "../CMP_node.h"
 #include "node_util.h"

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2007-09-23 18:22:18 UTC (rev 12124)
+++ trunk/blender/source/blender/src/buttons_editing.c	2007-09-23 18:27:01 UTC (rev 12125)
@@ -3097,6 +3097,7 @@
 	
 	uiDefBut(block, LABEL, 10, "Lens:", 10, 180, 150, 20, 0, 0.0, 0.0, 0, 0, "");
 	
+	uiBlockBeginAlign(block);
 	if(cam->type==CAM_ORTHO) {
 		uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:",
 				  10, 160, 150, 20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera");
@@ -3115,59 +3116,57 @@
 		uiDefButS(block, TOG|BIT|5, B_REDR, "D",
 			140, 160, 20, 20, &cam->flag, 0, 0, 0, 0, "Use degree as the unit of the camera lens");
 	}
+	uiDefButS(block, TOG, REDRAWVIEW3D, "Orthographic",
+		  10, 140, 150, 20, &cam->type, 0, 0, 0, 0, "Render with orthographic projection (no prespective)");
+	uiBlockEndAlign(block);
 
 /* qdn: focal dist. param. from yafray now enabled for Blender as well, to use with defocus composit node */
-	uiDefButF(block, NUM, REDRAWVIEW3D, "DoFDist:", 10, 140, 150, 20 /*0, 125, 150, 20*/, &cam->YF_dofdist, 0.0, 5000.0, 50, 0, "Sets distance to point of focus (enable 'Limits' to make visible in 3Dview)");
-
-	uiDefButS(block, TOG, REDRAWVIEW3D, "Orthographic",
-			  10, 115, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally");
-			  //10, 135, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally");
+	uiBlockBeginAlign(block);
+	uiDefButF(block, NUM, REDRAWVIEW3D, "Dof Dist:", 10, 110, 150, 20 /*0, 125, 150, 20*/, &cam->YF_dofdist, 0.0, 5000.0, 50, 0, "Sets distance to point of focus (enable 'Limits' to make visible in 3Dview)");
+	uiDefIDPoinBut(block, test_obpoin_but, ID_OB, REDRAWVIEW3D, "Dof Ob:",	10, 90, 150, 20, &cam->dof_ob, "Focus on this object (overrides the 'Dof Dist')");
+	uiBlockEndAlign(block);
 	
-	uiDefBut(block, LABEL, 0, "Clipping:", 10, 90, 150, 20, 0, 0.0, 0.0, 0, 0, "");
+	uiDefBut(block, LABEL, 0, "Clipping Start/End:", 10, 45, 150, 20, 0, 0.0, 0.0, 0, 0, "");
 	
 	uiBlockBeginAlign(block);
 	uiDefButF(block, NUM,REDRAWVIEW3D, "Start:",
-			  10, 70, 150, 20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view");
+			  10, 25, 150, 20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Clip out geometry closer then this distance to the camera");
 	uiDefButF(block, NUM,REDRAWVIEW3D, "End:",
-			  10, 50, 150, 20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Specify the endvalue of the the field of view");
+			  10, 5, 150, 20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Clip out geometry further then this distance to the camera");
 	uiBlockEndAlign(block);
-			
-	uiDefButF(block, NUM,REDRAWVIEW3D, "Size:",
-			  170, 25, 150, 20, &cam->drawsize, 0.1*grid, 10.0, 10, 0, "The size that the camera is displayed in the 3D View (different from the object's scale)");
-
-	uiDefBut(block, LABEL, 0, "Shift:", 10, 25, 150, 20, 0, 0.0, 0.0, 0, 0, "");
-				  
-	uiBlockBeginAlign(block);
-	uiDefButF(block, NUM,REDRAWVIEW3D, "X:",
-		10, 5, 75, 20, &cam->shiftx, -2.0, 2.0, 1, 2, "Horizontally shifts the camera view, without changing the perspective");
-	uiDefButF(block, NUM,REDRAWVIEW3D, "Y:",
-		85, 5, 75, 20, &cam->shifty, -2.0, 2.0, 1, 2, "Vertically shifts the camera view, without changing the perspective");
-	uiBlockEndAlign(block);
 	
 	uiDefBut(block, LABEL, 0, "Show:", 170, 180, 150, 20, 0, 0.0, 0.0, 0, 0, "");
 
 	uiBlockBeginAlign(block);
 	uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Limits",
-			  170, 160, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw the field of view");
+			  170, 160, 75, 20, &cam->flag, 0, 0, 0, 0, "Draw the clipping range and the focal point");
 	uiDefButS(block, TOG|BIT|1, REDRAWVIEW3D, "Mist",
-			  170, 140, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area");
-	uiBlockEndAlign(block);
+			  245, 160, 75, 20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area");
 	
-	uiBlockBeginAlign(block);
 	uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Name",
-			  170, 115, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw the active camera's name in camera view");
+			  170, 140, 75, 20, &cam->flag, 0, 0, 0, 0, "Draw the active camera's name in camera view");
 		uiDefButS(block, TOG|BIT|3, REDRAWVIEW3D, "Title Safe",
-			  170, 95, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a the title safe zone in camera view");
+			  245, 140, 75, 20, &cam->flag, 0, 0, 0, 0, "Draw a the title safe zone in camera view");
 	uiBlockEndAlign(block);
 	
-	uiBlockBeginAlign(block);	
+	uiBlockBeginAlign(block);
 	uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Passepartout",
-			  170, 70, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a darkened passepartout over the off-screen area in camera view");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list