Index: source/blender/blenkernel/intern/scene.c =================================================================== --- source/blender/blenkernel/intern/scene.c (revision 13237) +++ source/blender/blenkernel/intern/scene.c (working copy) @@ -171,6 +171,15 @@ MEM_freeN(sce->nodetree); } + if(sce->stored_vd1) + MEM_freeN(sce->stored_vd1); + if(sce->stored_vd2) + MEM_freeN(sce->stored_vd2); + if(sce->stored_vd3) + MEM_freeN(sce->stored_vd3); + if(sce->stored_vd4) + MEM_freeN(sce->stored_vd4); + sculptdata_free(sce); } Index: source/blender/python/api2_2x/Curve.c =================================================================== --- source/blender/python/api2_2x/Curve.c (revision 13237) +++ source/blender/python/api2_2x/Curve.c (working copy) @@ -1,5 +1,5 @@ /* - * $Id: Curve.c 12752 2007-12-01 23:25:00Z campbellbarton $ + * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * Index: source/blender/python/api2_2x/Metaball.c =================================================================== --- source/blender/python/api2_2x/Metaball.c (revision 13237) +++ source/blender/python/api2_2x/Metaball.c (working copy) @@ -1,5 +1,5 @@ /* - * $Id: Metaball.c 11136 2007-07-01 05:41:23Z campbellbarton $ + * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * Index: source/blender/python/api2_2x/meshPrimitive.c =================================================================== --- source/blender/python/api2_2x/meshPrimitive.c (revision 13237) +++ source/blender/python/api2_2x/meshPrimitive.c (working copy) @@ -1,5 +1,5 @@ /* - * $Id: meshPrimitive.c 10773 2007-05-24 15:00:10Z khughes $ + * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * @@ -33,12 +33,18 @@ #include "Mesh.h" /*This must come first*/ #include "DNA_scene_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" + #include "BDR_editobject.h" #include "BIF_editmesh.h" #include "BKE_global.h" #include "BKE_object.h" #include "BKE_scene.h" #include "BKE_library.h" +#include "BKE_utildefines.h" +#include "BLI_arithb.h" +#include "BSE_view.h" #include "blendef.h" #include "gen_utils.h" @@ -51,13 +57,27 @@ static PyObject *make_mesh( int type, char *name, short tot, short seg, short subdiv, float dia, float height, short ext, short fill ) { - float cent[3] = {0,0,0}; - float imat[3][3]={{1,0,0},{0,1,0},{0,0,1}}; + float imat[3][3], cmat[3][3], mat[3][3]; + float cent[3]; + float *curs; Mesh *me; BPy_Mesh *obj; Object *ob; Base *base; + curs= give_cursor(); + VECCOPY(cent, curs); + cent[0]-= G.obedit->obmat[3][0]; + cent[1]-= G.obedit->obmat[3][1]; + cent[2]-= G.obedit->obmat[3][2]; + + /* add view aligned option */ + if(U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, G.vd->viewmat); + else Mat3One(imat); + Mat3MulVecfl(imat, cent); + Mat3MulMat3(cmat, imat, mat); + Mat3Inv(imat,cmat); + /* remember active object (if any) for later, so we can re-activate */ base = BASACT; @@ -77,7 +97,14 @@ cent ); /* location of center */ /* copy primitive back to the real mesh */ - load_editMesh( ); + //load_editMesh( ); + + if(U.flag & USER_ADD_EDITMODE) { + load_editMesh(); + } else { + exit_editmode(2); + } + free_editMesh( G.editMesh ); G.obedit = NULL; Index: source/blender/makesdna/DNA_scene_types.h =================================================================== --- source/blender/makesdna/DNA_scene_types.h (revision 13237) +++ source/blender/makesdna/DNA_scene_types.h (working copy) @@ -512,6 +512,9 @@ /* Sculptmode data */ struct SculptData sculptdata; + + /* Stored views */ + struct storeView3D *stored_vd1, *stored_vd2, *stored_vd3, *stored_vd4; } Scene; Index: source/blender/makesdna/DNA_view3d_types.h =================================================================== --- source/blender/makesdna/DNA_view3d_types.h (revision 13237) +++ source/blender/makesdna/DNA_view3d_types.h (working copy) @@ -66,6 +66,20 @@ short xim, yim; } BGpic; +typedef struct storeView3D { + float viewquat[4], dist, zfac; /* zfac is initgrabz() result */ + + /** + * 0 - ortho + * 1 - do 3d perspective + * 2 - use the camera + */ + short persp; + short view; + + int lay, layact; +} storeView3D; + typedef struct View3D { struct SpaceLink *next, *prev; int spacetype; Index: source/blender/src/editview.c =================================================================== --- source/blender/src/editview.c (revision 13237) +++ source/blender/src/editview.c (working copy) @@ -923,6 +923,89 @@ return 0; } +/* save/store view */ +void store_view3d(){ + storeView3D *s; + int v=1,i; + if( saveview_buts(&v, NULL)==0 ) return; + switch(v){ + case 1: + if(G.scene->stored_vd1==NULL) + G.scene->stored_vd1=MEM_mallocN(sizeof(storeView3D), "store view buffer"); + s= G.scene->stored_vd1; + break; + case 2: + if(G.scene->stored_vd2==NULL) + G.scene->stored_vd2=MEM_mallocN(sizeof(storeView3D), "store view buffer"); + s= G.scene->stored_vd2; + break; + case 4: + if(G.scene->stored_vd3==NULL) + G.scene->stored_vd3=MEM_mallocN(sizeof(storeView3D), "store view buffer"); + s= G.scene->stored_vd3; + break; + case 8: + if(G.scene->stored_vd4==NULL) + G.scene->stored_vd4=MEM_mallocN(sizeof(storeView3D), "store view buffer"); + s= G.scene->stored_vd4; + break; + } + + for(i=0;i<4;i++){ + s->viewquat[i]=G.vd->viewquat[i]; + } + s->dist=G.vd->dist; + s->zfac=G.vd->zfac; + s->lay=G.vd->lay; + s->layact=G.vd->layact; + s->persp=G.vd->persp; + s->view=G.vd->view; +} +void load_view3d(){ + storeView3D *s=0; + int v=1,i; + if( saveview_buts(&v, NULL)==0 ) return; + switch(v){ + case 1: + if(G.scene->stored_vd1==NULL) + printf("No stored view\n"); + else + s= G.scene->stored_vd1; + break; + case 2: + if(G.scene->stored_vd2==NULL) + printf("No stored view\n"); + else + s= G.scene->stored_vd2; + break; + case 4: + if(G.scene->stored_vd3==NULL) + printf("No stored view\n"); + else + s= G.scene->stored_vd3; + break; + case 8: + if(G.scene->stored_vd4==NULL) + printf("No stored view\n"); + else + s= G.scene->stored_vd4; + break; + } + if(s==NULL) + return; + for(i=0;i<4;i++){ + G.vd->viewquat[i]=s->viewquat[i]; + } + G.vd->dist=s->dist; + G.vd->zfac=s->zfac; + G.vd->lay=s->lay; + G.vd->layact=s->layact; + G.vd->persp=s->persp; + G.vd->view=s->view; + + allqueue(REDRAWVIEW3D, 0); +} + void mouse_cursor(void) { float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3]; Index: source/blender/src/space.c =================================================================== --- source/blender/src/space.c (revision 13237) +++ source/blender/src/space.c (working copy) @@ -2497,6 +2497,9 @@ if ((G.obedit) && G.obedit->type==OB_MESH) { Vertex_Menu(); } + else { + store_view3d(); + } } else if((G.qual==LR_SHIFTKEY)) { if ((G.obedit) && G.obedit->type==OB_MESH) { align_view_to_selected(v3d); @@ -2507,6 +2510,8 @@ } else if(G.qual==LR_ALTKEY) image_aspect(); + else if(G.qual==(LR_CTRLKEY|LR_SHIFTKEY)) + load_view3d(); else if (G.qual==0){ if(G.obedit) { if(G.obedit->type==OB_MESH) { Index: source/blender/src/header_view3d.c =================================================================== --- source/blender/src/header_view3d.c (revision 13237) +++ source/blender/src/header_view3d.c (working copy) @@ -603,7 +603,13 @@ break; case 20: /* Transform Space Panel */ add_blockhandler(curarea, VIEW3D_HANDLER_TRANSFORM, UI_PNL_UNSTOW); - break; + break; + case 21: + store_view3d(); + break; + case 22: + load_view3d(); + break; } allqueue(REDRAWVIEW3D, 1); } @@ -621,7 +627,9 @@ uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Render Preview...|Shift P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 18, ""); uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Properties...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 16, ""); uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Background Image...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 15, ""); - + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save view...|Ctrl V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 21, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Load view...|Ctrl Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); if ((G.vd->viewbut == 0) && !(G.vd->persp == 2)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); @@ -675,6 +683,7 @@ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBlockBut(block, view3d_view_spacehandlers, NULL, ICON_RIGHTARROW_THIN, "Space Handler Scripts", 0, yco-=20, 120, 19, ""); + if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } Index: source/blender/src/toolbox.c =================================================================== --- source/blender/src/toolbox.c (revision 13237) +++ source/blender/src/toolbox.c (working copy) @@ -362,6 +362,62 @@ return 0; } +/* save view3d positions and layers */ +int saveview_buts(unsigned int *view, char *title) +{ + uiBlock *block; + ListBase listb={0, 0}; + int dx, dy, a, x1, y1, sizex=80, sizey=30; + short pivot[2], mval[2], ret=0; + + if(G.vd->localview) { + error("Not in localview "); + return ret; + } + + getmouseco_sc(mval); + + pivot[0]= CLAMPIS(mval[0], (sizex+10), G.curscreen->sizex-30); + pivot[1]= CLAMPIS(mval[1], (sizey/2)+10, G.curscreen->sizey-(sizey/2)-10); + + if (pivot[0]!=mval[0] || pivot[1]!=mval[1]) + warp_pointer(pivot[0], pivot[1]); + + mywinset(G.curscreen->mainwin); + + x1= pivot[0]-sizex+10; + y1= pivot[1]-sizey/2; + + block= uiNewBlock(&listb, "button", UI_EMBOSS, UI_HELV, G.curscreen->mainwin); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_ENTER_OK); + + dx= 15;//(sizex-5)/12; + dy= sizey/2; + + if(title) + uiDefBut(block, LABEL, 0, title, (short)(x1), (short)y1+30, sizex, 20, NULL, 1, 0, 0, 0, ""); + + /* buttons have 0 as return event, to prevent menu to close on hotkeys */ + uiBlockBeginAlign(block); + uiDefButBitI(block, TOGR, 1, 0, "",(short)(x1+dx),(short)(y1+dy),(short)dx,(short)dy, (int *)view, 0, 0, 0, 0, ""); + uiDefButBitI(block, TOGR, 2, 0, "",(short)(x1+2*dx),(short)(y1+dy),(short)dx,(short)dy, (int *)view, 0, 0, 0, 0, ""); + + uiDefButBitI(block, TOGR, 4, 0, "",(short)(x1+dx),(short)y1,(short)dx,(short)dy, (int *)view, 0, 0, 0, 0, ""); + uiDefButBitI(block, TOGR, 8, 0, "",(short)(x1+2*dx),(short)y1,(short)dx,(short)dy, (int *)view, 0, 0, 0, 0, ""); + + uiBlockEndAlign(block); + + + uiDefBut(block, BUT, 32767, "OK", (short)(x1+3*dx+10), (short)y1, (short)(3*dx), (short)(2*dy), NULL, 0, 0, 0, 0, ""); + + uiBoundsBlock(block, 2); + + ret= uiDoBlocks(&listb, 0, 0); + + if(ret==UI_RETURN_OK) return 1; + return 0; +} + int movetolayer_buts(unsigned int *lay, char *title) { uiBlock *block; Index: source/blender/blenloader/intern/writefile.c =================================================================== --- source/blender/blenloader/intern/writefile.c (revision 13237) +++ source/blender/blenloader/intern/writefile.c (working copy) @@ -1517,7 +1517,16 @@ writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree); write_nodetree(wd, sce->nodetree); } - + /* write store data */ + if(sce->stored_vd1) + writestruct(wd, DATA, "View3D", 1, sce->stored_vd1); + if(sce->stored_vd2) + writestruct(wd, DATA, "View3D", 1, sce->stored_vd2); + if(sce->stored_vd3) + writestruct(wd, DATA, "View3D", 1, sce->stored_vd3); + if(sce->stored_vd4) + writestruct(wd, DATA, "View3D", 1, sce->stored_vd4); + sce= sce->id.next; } /* flush helps the compression for undo-save */ Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (revision 13237) +++ source/blender/blenloader/intern/readfile.c (working copy) @@ -3331,7 +3331,12 @@ sce->basact= newdataadr(fd, sce->basact); sce->radio= newdataadr(fd, sce->radio); - + + sce->stored_vd1= newdataadr(fd, sce->stored_vd1); + sce->stored_vd2= newdataadr(fd, sce->stored_vd2); + sce->stored_vd3= newdataadr(fd, sce->stored_vd3); + sce->stored_vd4= newdataadr(fd, sce->stored_vd4); + sce->toolsettings= newdataadr(fd, sce->toolsettings); sce->sculptdata.session= NULL; Index: source/blender/nodes/intern/CMP_nodes/CMP_radialblur.c =================================================================== Index: source/blender/nodes/intern/CMP_nodes/CMP_autofocus.c ===================================================================