Index: source/blender/blenkernel/BKE_object.h =================================================================== --- source/blender/blenkernel/BKE_object.h (revision 12104) +++ source/blender/blenkernel/BKE_object.h (working copy) @@ -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); Index: source/blender/blenkernel/intern/object.c =================================================================== --- source/blender/blenkernel/intern/object.c (revision 12104) +++ source/blender/blenkernel/intern/object.c (working copy) @@ -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; Index: source/blender/blenkernel/intern/depsgraph.c =================================================================== --- source/blender/blenkernel/intern/depsgraph.c (revision 12104) +++ source/blender/blenkernel/intern/depsgraph.c (working copy) @@ -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; Index: source/blender/makesdna/DNA_camera_types.h =================================================================== --- source/blender/makesdna/DNA_camera_types.h (revision 12104) +++ source/blender/makesdna/DNA_camera_types.h (working copy) @@ -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 ********************* */ Index: source/blender/src/drawobject.c =================================================================== --- source/blender/src/drawobject.c (revision 12104) +++ source/blender/src/drawobject.c (working copy) @@ -1096,7 +1096,7 @@ if(cam->flag & CAM_SHOWLIMITS) { draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); /* qdn: was yafray only, now also enabled for Blender to be used with defocus composit node */ - draw_focus_cross(cam->YF_dofdist, cam->drawsize); + draw_focus_cross(dof_camera(ob), cam->drawsize); } wrld= G.scene->world; Index: source/blender/src/buttons_editing.c =================================================================== --- source/blender/src/buttons_editing.c (revision 12104) +++ source/blender/src/buttons_editing.c (working copy) @@ -3118,18 +3118,19 @@ /* 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)"); - + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, REDRAWVIEW3D, "DoFOb:", 10, 120, 150, 20, &cam->dof_ob, ""); + uiDefButS(block, TOG, REDRAWVIEW3D, "Orthographic", - 10, 115, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally"); + 10, 95, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally"); //10, 135, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally"); - uiDefBut(block, LABEL, 0, "Clipping:", 10, 90, 150, 20, 0, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Clipping Start/End:", 10, 70, 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, 50, 75, 20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view"); 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"); + 85, 50, 75, 20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Specify the endvalue of the the field of view"); uiBlockEndAlign(block); uiDefButF(block, NUM,REDRAWVIEW3D, "Size:", Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (revision 12104) +++ source/blender/blenloader/intern/readfile.c (working copy) @@ -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; Index: source/blender/nodes/intern/CMP_util.h =================================================================== --- source/blender/nodes/intern/CMP_util.h (revision 12104) +++ source/blender/nodes/intern/CMP_util.h (working copy) @@ -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" Index: source/blender/nodes/intern/CMP_nodes/CMP_defocus.c =================================================================== --- source/blender/nodes/intern/CMP_nodes/CMP_defocus.c (revision 12104) +++ source/blender/nodes/intern/CMP_nodes/CMP_defocus.c (working copy) @@ -257,7 +257,7 @@ 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 = MAX2(1e10f, dof_camera(camob)); cam_invfdist = 1.f/cam_fdist; }