Added baking for softbodies.
[blender.git] / source / blender / src / space.c
index 6d963870669cd0d9d646ffbddd7d8c6ef040361d..dadfbf0f0b23bb3997434082b2ed84f4590926ca 100644 (file)
 
 #include "BIF_transform.h"
 
+#include "BKE_depsgraph.h"
+
 #include "TPT_DependKludge.h"
 #ifdef NAN_TPT
 #include "BSE_trans_types.h"
@@ -713,7 +715,6 @@ void BIF_undo_menu(void)
 
 static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
 {
-       static short prev_event= 0;             // used to detect an alt/ctrl/shift event
        unsigned short event= evt->event;
        short val= evt->val;
        char ascii= evt->ascii;
@@ -729,8 +730,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
                if(event==MOUSEY || event==MOUSEX) return;
                
-               prev_event= event;      // for ctrl/alt/shift event
-               
                if(event==UI_BUT_EVENT) do_butspace(val); // temporal, view3d deserves own queue?
                
                /* we consider manupilator a button, defaulting to leftmouse */
@@ -1057,6 +1056,34 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                do_layer_buttons(11); break;
                        case ACCENTGRAVEKEY:
                                do_layer_buttons(-1); break;
+                       
+                       case SPACEKEY:
+                               if(G.qual == LR_CTRLKEY) {
+                                       val= pupmenu("Manipulator%t|Enable/Disable|Translate|Rotate|Scale|Combo");
+                                       if(val>0) {
+                                               if(val==1) v3d->twflag ^= V3D_USE_MANIPULATOR;
+                                               else {
+                                                       if(val==2) v3d->twtype= V3D_MANIP_TRANSLATE;
+                                                       else if(val==3) v3d->twtype= V3D_MANIP_ROTATE;
+                                                       else if(val==4) v3d->twtype= V3D_MANIP_SCALE;
+                                                       else if(val==5) v3d->twtype= V3D_MANIP_TRANSLATE|V3D_MANIP_ROTATE|V3D_MANIP_SCALE;
+                                                       v3d->twflag |= V3D_USE_MANIPULATOR;
+                                               }
+                                               doredraw= 1;
+                                       }
+                               }
+                               else if(G.qual == LR_ALTKEY) {
+                                       val= pupmenu("Manipulator Orientation%t|Global|Local|Normal");
+                                       if(val>0) {
+                                               if(val==1) v3d->twmode= V3D_MANIP_GLOBAL;
+                                               else if(val==2) v3d->twmode= V3D_MANIP_LOCAL;
+                                               else if(val==3) v3d->twmode= V3D_MANIP_NORMAL;
+                                               v3d->twflag |= V3D_USE_MANIPULATOR;
+                                               doredraw= 1;
+                                       }
+                               }
+
+                               break;
                                
                        case AKEY:
                                if(G.qual & LR_CTRLKEY) apply_object(); // also with shift!
@@ -1183,7 +1210,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                }
                                else if (G.qual==LR_SHIFTKEY) {
                                        if (G.obedit && G.obedit->type==OB_MESH) {
-                                               transform('e');
+                                               Transform(TFM_CREASE, CTX_EDGE);
                                        }
                                }
                                break;
@@ -1219,8 +1246,13 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        if(okee("Clear location")) {
                                                clear_object('g');
                                        }
-                               } else if((G.qual==0)) {
-                                       Transform(TFM_TRANSLATION);
+                               }
+                               else if(G.qual== (LR_CTRLKEY|LR_ALTKEY)) {
+                                       v3d->twtype= V3D_MANIP_TRANSLATE;
+                                       doredraw= 1;
+                               }
+                               else if((G.qual==0)) {
+                                       Transform(TFM_TRANSLATION, CTX_NONE);
                                }
                                break;
                        case HKEY:
@@ -1351,14 +1383,22 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                selectconnected_posearmature();
                                }
                                else {
-                                       if((G.qual==LR_SHIFTKEY))
-                                               selectlinks_menu();
-                                       else if(G.qual==LR_CTRLKEY)
-                                               make_links_menu();
-                                       else if(G.f & G_FACESELECT)
-                                               select_linked_tfaces();
-                                       else if((G.qual==0))
-                                               make_local();
+                                       if(G.f & G_FACESELECT) {
+                                               if((G.qual==0))
+                                                       select_linked_tfaces(0);
+                                               else if((G.qual==LR_SHIFTKEY))
+                                                       select_linked_tfaces(1);
+                                               else if(G.qual==LR_CTRLKEY)
+                                                       select_linked_tfaces(2);
+                                       }
+                                       else {
+                                               if((G.qual==0))
+                                                       make_local();
+                                               else if((G.qual==LR_SHIFTKEY))
+                                                       selectlinks_menu();
+                                               else if(G.qual==LR_CTRLKEY)
+                                                       make_links_menu();
+                                       }
                                }
                                break;
                        case MKEY:
@@ -1420,16 +1460,18 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case OKEY:
                                ob= OBACT;
-                               if (G.qual==LR_SHIFTKEY) {
-                                       extern int prop_mode;
-                                       prop_mode = (prop_mode+1)%5;
-                                       allqueue(REDRAWHEADERS, 0);
-                               }
-                               else if((G.qual==0)) {
-                                       G.f ^= G_PROPORTIONAL;
-                                       allqueue(REDRAWHEADERS, 0);
+                               if (G.obedit) {
+                                       if (G.qual==LR_SHIFTKEY) {
+                                               extern int prop_mode;
+                                               prop_mode = (prop_mode+1)%6;
+                                               allqueue(REDRAWHEADERS, 0);
+                                       }
+                                       else if((G.qual==0)) {
+                                               G.f ^= G_PROPORTIONAL;
+                                               allqueue(REDRAWHEADERS, 0);
+                                       }
                                }
-                               else if((G.qual==LR_CTRLKEY)) {
+                               else if((G.qual==LR_SHIFTKEY)) {
                                        if(ob && ob->type == OB_MESH) {
                                                flip_subdivison(ob, -1);
                                        }
@@ -1442,7 +1484,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
 
                        case PKEY:
-                               
                                if(G.obedit) {
                                        if(G.qual==LR_CTRLKEY || G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
                                                make_parent();
@@ -1450,9 +1491,13 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                separatemenu();
                                        else if ((G.qual==0) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
                                                separate_nurb();
+                                       else if (G.qual==LR_SHIFTKEY)
+                                               Transform(TFM_PUSHPULL, CTX_NONE);
                                }
                                else if(G.qual==LR_CTRLKEY || G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
                                        make_parent();
+                               else if(G.qual==LR_SHIFTKEY)
+                                       Transform(TFM_PUSHPULL, CTX_NONE);
                                else if(G.qual==LR_ALTKEY)
                                        clear_parent();
                                else if((G.qual==0)) {
@@ -1466,7 +1511,12 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        if(okee("Clear rotation")) {
                                                clear_object('r');
                                        }
-                               } else if (G.obedit) {
+                               } 
+                               else if(G.qual== (LR_CTRLKEY|LR_ALTKEY)) {
+                                       v3d->twtype= V3D_MANIP_ROTATE;
+                                       doredraw= 1;
+                               }
+                               else if (G.obedit) {
                                        if((G.qual==LR_SHIFTKEY)) {
                                                if ELEM(G.obedit->type,  OB_CURVE, OB_SURF)                                     
                                                        selectrow_nurb();
@@ -1478,28 +1528,32 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                        loopoperations(LOOP_CUT);
                                        }
                                        else if((G.qual==0)) {
-                                               Transform(TFM_ROTATION);
+                                               Transform(TFM_ROTATION, CTX_NONE);
                                        }
                                }
                                else if((G.qual==0)) {
-                                       Transform(TFM_ROTATION);
+                                       Transform(TFM_ROTATION, CTX_NONE);
                                }
                                break;
                        case SKEY:
-                               if(G.obedit) {
+                               if(G.qual== (LR_CTRLKEY|LR_ALTKEY)) {
+                                       v3d->twtype= V3D_MANIP_SCALE;
+                                       doredraw= 1;
+                               }
+                               else if(G.obedit) {
                                        if(G.qual==LR_ALTKEY)
-                                               Transform(TFM_SHRINKFATTEN);
+                                               Transform(TFM_SHRINKFATTEN, CTX_NONE);
                                        else if(G.qual==LR_CTRLKEY)
-                                               Transform(TFM_SHEAR);
+                                               Transform(TFM_SHEAR, CTX_NONE);
                                        else if(G.qual==(LR_CTRLKEY|LR_ALTKEY))
-                                               Transform(TFM_SHEAR);
+                                               Transform(TFM_SHEAR, CTX_NONE);
                                        else if(G.qual==LR_SHIFTKEY)
                                                snapmenu();
                                        else if(G.qual==0) {
-                                               Transform(TFM_RESIZE);
+                                               Transform(TFM_RESIZE, CTX_NONE);
                                        }
                                        else if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY)){
-                                               Transform(TFM_TOSPHERE);
+                                               Transform(TFM_TOSPHERE, CTX_NONE);
                                        }
                                        
                                }
@@ -1512,12 +1566,12 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        snapmenu();
                                }
                                else if((G.qual==0)) {
-                                       Transform(TFM_RESIZE);
+                                       Transform(TFM_RESIZE, CTX_NONE);
                                }
                                else if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
-                                       Transform(TFM_TOSPHERE);
+                                       Transform(TFM_TOSPHERE, CTX_NONE);
                                else if(G.qual==(LR_CTRLKEY|LR_ALTKEY))
-                                       Transform(TFM_SHEAR);
+                                       Transform(TFM_SHEAR, CTX_NONE);
                                break;
                        case TKEY:
                                if(G.obedit){
@@ -1532,7 +1586,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                        clear_tilt();
                                                }
                                                else if (G.qual==0) {
-                                                       Transform(TFM_TILT);
+                                                       Transform(TFM_TILT, CTX_NONE);
                                                }
                                        }
                                }
@@ -1598,7 +1652,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case WKEY:
                                if((G.qual==LR_SHIFTKEY)) {
-                                       Transform(TFM_WARP);
+                                       Transform(TFM_WARP, CTX_NONE);
                                }
                                else if(G.qual==LR_ALTKEY) {
                                        /* if(G.obedit && G.obedit->type==OB_MESH) write_videoscape(); */
@@ -1749,25 +1803,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        }
                }
        }
-       else {  // val==0, hotkeys for ctrl/alt/shift
-               if(prev_event==event) {
-                       switch(event) {
-                               
-                       case RIGHTCTRLKEY: 
-                       case LEFTCTRLKEY:
-                               if(v3d->twflag & V3D_USE_MANIPULATOR) {
-                                       if(v3d->twtype & V3D_MANIPULATOR_TRANSLATE)
-                                               v3d->twtype= V3D_MANIPULATOR_ROTATE;
-                                       else if(v3d->twtype & V3D_MANIPULATOR_ROTATE)
-                                               v3d->twtype= V3D_MANIPULATOR_SCALE;
-                                       else if(v3d->twtype & V3D_MANIPULATOR_SCALE)
-                                               v3d->twtype= V3D_MANIPULATOR_TRANSLATE;
-                                       doredraw= 1;
-                               }
-                               break;
-                       }
-               }
-       }
        
        if(doredraw) {
                scrarea_queue_winredraw(curarea);
@@ -2483,11 +2518,9 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                                         (xpos+edgsp+(5*mpref)+(6*midsp)+(mpref/2)),y5,(mpref/2),buth,
                                         &(U.tw_handlesize), 2, 40, 0, 0, "Size of widget handles as percentage of widget radius");
                uiDefButS(block, NUM, B_REDRCURW3D, "Hotspot:",
-                                 (xpos+edgsp+(5*mpref)+(6*midsp)),y4,(mpref/2),buth,
+                                 (xpos+edgsp+(5*mpref)+(6*midsp)),y4,(mpref),buth,
                                  &(U.tw_hotspot), 4, 40, 0, 0, "Hotspot in pixels for clicking widget handles");
-               uiDefButBitS(block, TOG, U_TW_ABSOLUTE, B_REDRCURW3D, "Fixed Size",
-                                 (xpos+edgsp+(5*mpref)+(6*midsp)+(mpref/2)),y4,(mpref/2),buth,
-                                 &(U.tw_flag), 2, 40, 0, 0, "Size of widget based on fixed window size (1000 pixels)");
+               
                uiBlockEndAlign(block);
                
        } else if (U.userpref == 1) { /* edit methods */
@@ -2759,9 +2792,9 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        (xpos+edgsp+(4*midsp)+(4*mpref)),y3label,mpref,buth,
                        0, 0, 0, 0, 0, "");
 
-               uiDefButBitI(block, TOG, USER_DISABLE_SOUND, B_SOUNDTOGGLE, "Disable Sound",
+               uiDefButBitI(block, TOG, USER_DISABLE_SOUND, B_SOUNDTOGGLE, "Disable Game Sound",
                        (xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth,
-                       &(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played");
+                       &(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played in games");
 
                uiDefButBitS(block, TOG, USER_FILTERFILEEXTS, 0, "Filter File Extensions",
                        (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
@@ -3353,7 +3386,7 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                case GKEY:
                        if(sseq->mainb) break;
                        if((G.qual==0))
-                               transform_seq('g');
+                               transform_seq('g', 0);
                        break;
                case MKEY:
                        if(G.qual==LR_ALTKEY)
@@ -3732,9 +3765,6 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                if(G.qual & LR_SHIFTKEY) mouseco_to_curtile();
                                else gesture();
                                break;
-                       case MIDDLEMOUSE:
-                               image_viewmove();
-                               break;
                        case RIGHTMOUSE:
                                if(G.f & G_FACESELECT)
                                        mouse_select_sima();
@@ -3760,12 +3790,12 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        toggle_uv_select('f');
                                break;
                        case EKEY :
-                               if (okee("LSCM unwrap"))
+                               if(okee("LSCM Unwrap"))
                                        unwrap_lscm();
                                break;
                        case GKEY:
                                if((G.qual==0))
-                                       transform_tface_uv('g');
+                                       transform_tface_uv('g', 0);
                                break;
                        case HKEY:
                                if(G.qual==LR_ALTKEY)
@@ -3776,8 +3806,12 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        hide_tface_uv(0);
                                break;
                        case LKEY:
-                               if((G.qual==0))
-                                       select_linked_tface_uv();
+                               if(G.qual==0)
+                                       select_linked_tface_uv(0);
+                               else if(G.qual==LR_SHIFTKEY)
+                                       select_linked_tface_uv(1);
+                               else if(G.qual==LR_CTRLKEY)
+                                       select_linked_tface_uv(2);
                                else if(G.qual==LR_ALTKEY)
                                        unlink_selection();
                                break;
@@ -3809,11 +3843,11 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case RKEY:
                                if((G.qual==0))
-                                       transform_tface_uv('r');
+                                       transform_tface_uv('r', 0);
                                break;
                        case SKEY:
                                if((G.qual==0))
-                                       transform_tface_uv('s');
+                                       transform_tface_uv('s', 0);
                                break;
                        case VKEY:
                                if((G.qual==0))
@@ -3822,7 +3856,11 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        stitch_uv_tface(1);
                                break;
                        case WKEY:
-                               transform_tface_uv('w');
+                               weld_align_menu_tface_uv();
+                               break;
+                       case PADPERIOD:
+                               if(G.qual==0)
+                                       image_viewcentre();
                                break;
                }
        }       
@@ -3839,13 +3877,13 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                do_imagebuts(val);      // drawimage.c
                break;
        case MIDDLEMOUSE:
-               image_viewmove();
+               if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
+                       image_viewmove(1);
+               else
+                       image_viewmove(0);
                break;
-       case WHEELUPMOUSE:
-       case WHEELDOWNMOUSE:
-       case PADPLUSKEY:
-       case PADMINUS:
-               image_viewzoom(event);
+       case WHEELUPMOUSE: case WHEELDOWNMOUSE: case PADPLUSKEY: case PADMINUS:
+               image_viewzoom(event, 0);
                scrarea_queue_winredraw(curarea);
                break;
        case HOMEKEY:
@@ -4012,7 +4050,7 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        break;
                case GKEY:
                        if((G.qual==0))
-                               transform_oops('g');
+                               transform_oops('g', 0);
                        break;
                case LKEY:
                        if((G.qual==LR_SHIFTKEY))
@@ -4030,7 +4068,7 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        shuffle_oops();
                                }
                        } else if((G.qual==0)) {
-                               transform_oops('s');
+                               transform_oops('s', 0);
                        }
                        break;
                case PKEY:
@@ -4306,6 +4344,8 @@ void freespacelist(ListBase *lb)
                        SpaceFile *sfile= (SpaceFile*) sl;
                        if(sfile->libfiledata)  
                                BLO_blendhandle_close(sfile->libfiledata);
+                       if(sfile->filelist)
+                               freefilelist(sfile);
                }
                else if(sl->spacetype==SPACE_BUTS) {
                        SpaceButs *buts= (SpaceButs*) sl;
@@ -4443,6 +4483,16 @@ void allqueue(unsigned short event, short val)
 
        sa= G.curscreen->areabase.first;
        while(sa) {
+//#ifdef NAN_DEP_GRAPH
+               /* dependency check.maybe not final pos */
+               if (sa->spacetype==SPACE_VIEW3D) {
+                       if (G.scene->dagisvalid == 0) {
+//                             fprintf(stderr,"building dag \n");
+                               G.scene->theDag = build_dag(G.scene, DAG_RL_ALL_BUT_DATA_MASK);
+                               G.scene->dagisvalid = 1;
+                       }
+               }
+//#endif
                if(event==REDRAWALL) {
                        scrarea_queue_winredraw(sa);
                        scrarea_queue_headredraw(sa);