From 0096d180b924c1f1187d723a8e79ddc1b4c83586 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 23 Sep 2007 18:27:01 +0000 Subject: 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. --- source/blender/blenkernel/BKE_object.h | 1 + source/blender/blenkernel/intern/depsgraph.c | 9 +++- source/blender/blenkernel/intern/object.c | 28 +++++++++- source/blender/blenloader/intern/readfile.c | 6 +-- source/blender/makesdna/DNA_camera_types.h | 2 + .../blender/nodes/intern/CMP_nodes/CMP_defocus.c | 3 +- source/blender/nodes/intern/CMP_util.h | 1 + source/blender/src/buttons_editing.c | 59 +++++++++++----------- source/blender/src/drawobject.c | 2 +- source/blender/src/header_view3d.c | 10 ++-- source/blender/src/space.c | 4 +- 11 files changed, 82 insertions(+), 43 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 9022e07ebac..b834116f11d 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -63,6 +63,7 @@ int exist_object(struct Object *obtest); 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); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 8e2feba1e2f..7b869f8b0e8 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -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 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int 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; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 751887b9f42..ba8d047644b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -260,6 +260,7 @@ void unlink_object(Object *ob) Tex *tex; Ipo *ipo; Group *group; + Camera *camera; bConstraint *con; bActionStrip *strip; int a; @@ -473,6 +474,15 @@ void unlink_object(Object *ob) 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,7 +583,23 @@ void make_local_camera(Camera *cam) } } - +/* 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) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3631ed48a64..f0f3337f004 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1864,7 +1864,9 @@ static void lib_link_camera(FileData *fd, Main *main) 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 @@ static void do_versions(FileData *fd, Library *lib, Main *main) 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; diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index f25d8fd6412..4cb8ec25ebc 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -42,6 +42,7 @@ extern "C" { #endif struct Ipo; +struct Object; typedef struct Camera { ID id; @@ -62,6 +63,7 @@ typedef struct Camera { struct Ipo *ipo; ScriptLink scriptlink; + struct Object *dof_ob; } Camera; /* **************** CAMERA ********************* */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c b/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c index 1eecbf3b63e..ee68b81cde8 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c @@ -257,7 +257,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, 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; } diff --git a/source/blender/nodes/intern/CMP_util.h b/source/blender/nodes/intern/CMP_util.h index 515980bc563..83f85160625 100644 --- a/source/blender/nodes/intern/CMP_util.h +++ b/source/blender/nodes/intern/CMP_util.h @@ -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" diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 79aa9daa1db..0ff5d26646a 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -3097,6 +3097,7 @@ static void editing_panel_camera_type(Object *ob, Camera *cam) 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 @@ static void editing_panel_camera_type(Object *ob, Camera *cam) 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"); - 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"); + 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); 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"); + 170, 110, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a darkened passepartout over the off-screen area in camera view"); uiDefButF(block, NUMSLI, REDRAWVIEW3D, "Alpha: ", - 170, 50, 150, 20, &cam->passepartalpha, 0.0, 1.0, 0, 0, "The opacity (darkness) of the passepartout"); + 170, 90, 150, 20, &cam->passepartalpha, 0.0, 1.0, 0, 0, "The opacity (darkness) of the passepartout"); uiBlockEndAlign(block); - + uiDefButF(block, NUM,REDRAWVIEW3D, "Size:", + 170, 50, 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:", 170, 25, 150, 20, 0, 0.0, 0.0, 0, 0, ""); + + uiBlockBeginAlign(block); + uiDefButF(block, NUM,REDRAWVIEW3D, "X:", + 170, 5, 75, 20, &cam->shiftx, -2.0, 2.0, 1, 2, "Horizontally shift the camera view, without changing the perspective"); + uiDefButF(block, NUM,REDRAWVIEW3D, "Y:", + 245, 5, 75, 20, &cam->shifty, -2.0, 2.0, 1, 2, "Vertically shift the camera view, without changing the perspective"); + uiBlockEndAlign(block); } /* yafray: extra camera panel to set Depth-of-Field parameters */ diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index b61505901c8..47c2f9f82ae 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -1096,7 +1096,7 @@ static void drawcamera(Object *ob, int flag) 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; diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 57ddce2f9a1..d83509f09f8 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -4986,7 +4986,7 @@ void view3d_buttons(void) if(FACESEL_PAINT_TEST) G.vd->flag |= V3D_FACESELECT; uiDefIconTextButS(block, MENU, B_MODESELECT, (G.vd->modeselect),view3d_modeselect_pup() , - xco,0,126,20, &(G.vd->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, F, V, Ctrl Tab)"); + xco,0,126,20, &(G.vd->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); xco+= 126+8; @@ -5033,7 +5033,7 @@ void view3d_buttons(void) xco+= XIC+10; } else { /* Manipulators arnt used in weight paint mode */ - uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, around_pup(), xco,0,XIC+10,YIC, &(G.vd->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period) "); + uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, around_pup(), xco,0,XIC+10,YIC, &(G.vd->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period, Ctrl Period, Alt Period)"); xco+= XIC+10; @@ -5083,7 +5083,7 @@ void view3d_buttons(void) xco+= (a-2)*(XIC/2)+3; /* LOCK */ - uiDefIconButS(block, ICONTOG, B_SCENELOCK, ICON_UNLOCKED, xco+=XIC,0,XIC,YIC, &(G.vd->scenelock), 0, 0, 0, 0, "Locks layers and used Camera to Scene (Ctrl `)"); + uiDefIconButS(block, ICONTOG, B_SCENELOCK, ICON_UNLOCKED, xco+=XIC,0,XIC,YIC, &(G.vd->scenelock), 0, 0, 0, 0, "Locks Active Camera and layers to Scene (Ctrl `)"); xco+= XIC+10; } @@ -5115,7 +5115,7 @@ void view3d_buttons(void) } else { - uiDefIconButBitS(block, TOG, V3D_TRANSFORM_SNAP, B_REDR, ICON_SNAP_GEAR,xco,0,XIC,YIC, &G.vd->flag2, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab)"); + uiDefIconButBitS(block, TOG, V3D_TRANSFORM_SNAP, B_REDR, ICON_SNAP_GEAR,xco,0,XIC,YIC, &G.vd->flag2, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)"); xco+= XIC; } @@ -5134,7 +5134,7 @@ void view3d_buttons(void) xco+= XIC; uiBlockEndAlign(block); if(G.vd->drawtype > OB_WIRE) { - uiDefIconButBitS(block, TOG, V3D_ZBUF_SELECT, B_REDR, ICON_ORTHO, xco,0,XIC,YIC, &G.vd->flag, 1.0, 0.0, 0, 0, "Limit selection to visible (clipped with depth buffer)"); + uiDefIconButBitS(block, TOG, V3D_ZBUF_SELECT, B_REDR, ICON_ORTHO, xco,0,XIC,YIC, &G.vd->flag, 1.0, 0.0, 0, 0, "Occlude background geometry"); xco+= XIC; } xco+= 20; diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 71cb6f5f4fe..78b4af26d23 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -2475,7 +2475,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) case PERIODKEY: if(G.qual==LR_CTRLKEY) { G.vd->around= V3D_LOCAL; - } else if(G.qual==0) { + } else if(G.qual==LR_ALTKEY) { + G.vd->around= V3D_ACTIVE; + } else if(G.qual==0) { G.vd->around= V3D_CURSOR; } handle_view3d_around(); -- cgit v1.2.3