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.
This commit is contained in:
Campbell Barton 2007-09-23 18:27:01 +00:00
parent ba6a09f31d
commit 0096d180b9
11 changed files with 84 additions and 45 deletions

@ -63,6 +63,7 @@ int exist_object(struct Object *obtest);
void *add_camera(char *name); void *add_camera(char *name);
struct Camera *copy_camera(struct Camera *cam); struct Camera *copy_camera(struct Camera *cam);
void make_local_camera(struct Camera *cam); void make_local_camera(struct Camera *cam);
float dof_camera(struct Object *ob);
void *add_lamp(char *name); void *add_lamp(char *name);
struct Lamp *copy_lamp(struct Lamp *la); struct Lamp *copy_lamp(struct Lamp *la);
void make_local_lamp(struct Lamp *la); void make_local_lamp(struct Lamp *la);

@ -44,6 +44,7 @@
#include "DNA_action_types.h" #include "DNA_action_types.h"
#include "DNA_armature_types.h" #include "DNA_armature_types.h"
#include "DNA_curve_types.h" #include "DNA_curve_types.h"
#include "DNA_camera_types.h"
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_effect_types.h" #include "DNA_effect_types.h"
#include "DNA_group_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); dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB);
/* inverted relation, so addtoroot shouldn't be set to zero */ /* 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_DUPLI) {
if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
GroupObject *go; GroupObject *go;

@ -260,6 +260,7 @@ void unlink_object(Object *ob)
Tex *tex; Tex *tex;
Ipo *ipo; Ipo *ipo;
Group *group; Group *group;
Camera *camera;
bConstraint *con; bConstraint *con;
bActionStrip *strip; bActionStrip *strip;
int a; int a;
@ -473,6 +474,15 @@ void unlink_object(Object *ob)
rem_from_group(group, ob); rem_from_group(group, ob);
group= group->id.next; 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) 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) void *add_lamp(char *name)
{ {

@ -1864,7 +1864,9 @@ static void lib_link_camera(FileData *fd, Main *main)
if(ca->id.flag & LIB_NEEDLINK) { if(ca->id.flag & LIB_NEEDLINK) {
ca->ipo= newlibadr_us(fd, ca->id.lib, ca->ipo); 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); lib_link_scriptlink(fd, &ca->id, &ca->scriptlink);
ca->id.flag -= LIB_NEEDLINK; 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; if(arm->layer==0) arm->layer= 1;
} }
for(sce= main->scene.first; sce; sce= sce->id.next) { for(sce= main->scene.first; sce; sce= sce->id.next) {
bScreen *sc;
if(sce->jumpframe==0) sce->jumpframe= 10; if(sce->jumpframe==0) sce->jumpframe= 10;
if(sce->audio.mixrate==0) sce->audio.mixrate= 44100; if(sce->audio.mixrate==0) sce->audio.mixrate= 44100;

@ -42,6 +42,7 @@ extern "C" {
#endif #endif
struct Ipo; struct Ipo;
struct Object;
typedef struct Camera { typedef struct Camera {
ID id; ID id;
@ -62,6 +63,7 @@ typedef struct Camera {
struct Ipo *ipo; struct Ipo *ipo;
ScriptLink scriptlink; ScriptLink scriptlink;
struct Object *dof_ob;
} Camera; } Camera;
/* **************** CAMERA ********************* */ /* **************** CAMERA ********************* */

@ -257,7 +257,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
if (camob && camob->type==OB_CAMERA) { if (camob && camob->type==OB_CAMERA) {
Camera* cam = (Camera*)camob->data; Camera* cam = (Camera*)camob->data;
cam_lens = cam->lens; 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; cam_invfdist = 1.f/cam_fdist;
} }

@ -60,6 +60,7 @@
#include "BKE_texture.h" #include "BKE_texture.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "BKE_library.h" #include "BKE_library.h"
#include "BKE_object.h"
#include "../CMP_node.h" #include "../CMP_node.h"
#include "node_util.h" #include "node_util.h"

@ -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, ""); uiDefBut(block, LABEL, 10, "Lens:", 10, 180, 150, 20, 0, 0.0, 0.0, 0, 0, "");
uiBlockBeginAlign(block);
if(cam->type==CAM_ORTHO) { if(cam->type==CAM_ORTHO) {
uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:", 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"); 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", 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"); 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 */ /* 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)"); 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)");
uiDefButS(block, TOG, REDRAWVIEW3D, "Orthographic", 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')");
10, 115, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally"); uiBlockEndAlign(block);
//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, 45, 150, 20, 0, 0.0, 0.0, 0, 0, "");
uiBlockBeginAlign(block); uiBlockBeginAlign(block);
uiDefButF(block, NUM,REDRAWVIEW3D, "Start:", 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:", 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); uiBlockEndAlign(block);
uiDefBut(block, LABEL, 0, "Show:", 170, 180, 150, 20, 0, 0.0, 0.0, 0, 0, ""); uiDefBut(block, LABEL, 0, "Show:", 170, 180, 150, 20, 0, 0.0, 0.0, 0, 0, "");
uiBlockBeginAlign(block); uiBlockBeginAlign(block);
uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Limits", 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", 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"); 245, 160, 75, 20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area");
uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Name",
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",
245, 140, 75, 20, &cam->flag, 0, 0, 0, 0, "Draw a the title safe zone in camera view");
uiBlockEndAlign(block); uiBlockEndAlign(block);
uiBlockBeginAlign(block); 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");
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");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Passepartout", 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: ", 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); 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 */ /* yafray: extra camera panel to set Depth-of-Field parameters */

@ -1096,7 +1096,7 @@ static void drawcamera(Object *ob, int flag)
if(cam->flag & CAM_SHOWLIMITS) { if(cam->flag & CAM_SHOWLIMITS) {
draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
/* qdn: was yafray only, now also enabled for Blender to be used with defocus composit node */ /* 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; wrld= G.scene->world;

@ -4986,7 +4986,7 @@ void view3d_buttons(void)
if(FACESEL_PAINT_TEST) G.vd->flag |= V3D_FACESELECT; if(FACESEL_PAINT_TEST) G.vd->flag |= V3D_FACESELECT;
uiDefIconTextButS(block, MENU, B_MODESELECT, (G.vd->modeselect),view3d_modeselect_pup() , 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; xco+= 126+8;
@ -5033,7 +5033,7 @@ void view3d_buttons(void)
xco+= XIC+10; xco+= XIC+10;
} else { } else {
/* Manipulators arnt used in weight paint mode */ /* 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; xco+= XIC+10;
@ -5083,7 +5083,7 @@ void view3d_buttons(void)
xco+= (a-2)*(XIC/2)+3; xco+= (a-2)*(XIC/2)+3;
/* LOCK */ /* 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; xco+= XIC+10;
} }
@ -5115,7 +5115,7 @@ void view3d_buttons(void)
} }
else 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; xco+= XIC;
} }
@ -5134,7 +5134,7 @@ void view3d_buttons(void)
xco+= XIC; xco+= XIC;
uiBlockEndAlign(block); uiBlockEndAlign(block);
if(G.vd->drawtype > OB_WIRE) { 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+= XIC;
} }
xco+= 20; xco+= 20;

@ -2475,7 +2475,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case PERIODKEY: case PERIODKEY:
if(G.qual==LR_CTRLKEY) { if(G.qual==LR_CTRLKEY) {
G.vd->around= V3D_LOCAL; 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; G.vd->around= V3D_CURSOR;
} }
handle_view3d_around(); handle_view3d_around();